Jul-29-2019, 02:00 PM
The error you are getting in step 2 is because of the else clause, where you print 'Unknown Text'. You don't assign anything to code in that case. So when you try to return code on line 12, you haven't created anything named code, and Python gets confused. In that case I would set code to a dummy value, like an empty string or '???'.
One step three, you have three different things named code: the function on line 1, the loop variable on line 13, and the morse code value returned on line 15. Each time you assign the name code to something, you lose what it was assigned to before. So all three of those things need different names.
Note that the for variable should not be looping over letter. The instructions say to loop four times. You do that by looping over range(4). You also need a colon at the end of the for loop on line 13, and you need to indent each line of code that should be repeated after the for statement.
One step three, you have three different things named code: the function on line 1, the loop variable on line 13, and the morse code value returned on line 15. Each time you assign the name code to something, you lose what it was assigned to before. So all three of those things need different names.
Note that the for variable should not be looping over letter. The instructions say to loop four times. You do that by looping over range(4). You also need a colon at the end of the for loop on line 13, and you need to indent each line of code that should be repeated after the for statement.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures