Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help!
I am trying to create a function that shows a given course code is correct or not.
the course code starts with four letters and three numbers with space in-between them.
Wish you all a Merry Christmas.

Even If I take off the remaining 5 values from course_name  I am still getting this error.
<pre>course_name =str("SCIN", "MATC", "BCSE")
TypeError: decoding str is not supported


What I have tried:

def Course_Code(input_word):
    course_name =['SCIN', 'ENGG', 'MATC', 'BCSE', 'BCMS', 'ENGS', 'MGMT', 'COMM']
    course_number =(1,2,3,4,6)
    for CourseCode in input_word (course_name,'',course_number):
        if CourseCode == "SCIN 123":
            print("True")
        else:
            print("False")  
input_word = input("Please select menu choice: ")
Course_Code(input_word)   
Posted
Updated 4-Sep-21 1:58am
v8
Comments
Mr Bobcat 1-Jan-21 13:29pm    
use split on input_word, then check the course name and number separately, one as a string and another as an array of numbers so you can match that array with the array of course_number.

1 solution

The str function does not combine or concatenate strings: it takes up to three parameters, the last two of which describe how to convert the value: Python str() Function[^]

I have no idea what you are trying to do with that code, and I'm not sure you do either! I'd strongly suggest you do two things:
1) Re-read your course notes carefully.
2) Read your full homework question again, and then re-read your notes from the last lesson.

Then think about what exactly you have been told to do - the question often includes pretty much complete instructions!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900