+ 1

I need some help.

hi i have just written a code using the def function. it's my first time using it so please check out at my code and if you can help me https://code.sololearn.com/cExdOvdUx5UM/?ref=app

22nd Apr 2018, 6:43 PM
Nikos Semertzidis
Nikos Semertzidis - avatar
9 Antworten
+ 8
What would you like to do? If you need a user input taken and you want to react on it, you have to rearrange it. First, define the function: def user_input(letter): if letter == 'A': print("01000001") elif letter == 'B': print("01000010") ... Then ask for user input: letter = input('enter a CAPS LETTER') and finally, call the function you defined: user_input(letter)
22nd Apr 2018, 6:52 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
You have to stay consistent throughout the logical block and indent forward anytime you make a sub-block of any earlier block, so for example: abc def ghi jkl mno pqr stu vwxyz
22nd Apr 2018, 7:29 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
xLeva Pls refer to what Rahul sent you. His corrected code of yous works properly. Observe the indentation he maintains throughout the code. In Python, it's an obligatory element of the syntax -- to indent adequately :)
22nd Apr 2018, 8:55 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
You wrote a function,but didn't call it.You remove the function def part and insert single or double quotes around alphabets. Or use ord() to convert letter into ascii value and then to binary.
22nd Apr 2018, 6:49 PM
®️ahul Mathews™️
®️ahul Mathews™️ - avatar
+ 2
xLeva The problem is print statement in first if block is not indented properly.check it.And also elif and else should be properly indented.
22nd Apr 2018, 7:02 PM
®️ahul Mathews™️
®️ahul Mathews™️ - avatar
22nd Apr 2018, 7:22 PM
®️ahul Mathews™️
®️ahul Mathews™️ - avatar
0
Kuba Siekierzyński it has an intented block error. Every time i have this problem. i put all the print commands 2 spaces after the beginning. so how is that even possible?
22nd Apr 2018, 6:58 PM
Nikos Semertzidis
Nikos Semertzidis - avatar
0
Rahul Mathews can you showcase it to me a bit please?
22nd Apr 2018, 7:05 PM
Nikos Semertzidis
Nikos Semertzidis - avatar
0
now it has a invalid syntax error
22nd Apr 2018, 8:04 PM
Nikos Semertzidis
Nikos Semertzidis - avatar