0

When I run this script, it only outputs the first if statement and not the other elif statements, and gives E0F Errors... HELP

Whenever I run the attached script (Basic python calculator) I wrote, the console outputs "Quitting" and breaks regardless of if the Elif statements are met or not. If I remove first if statement and properly replace it with any mathematical calculation function as is shown in the elif statements, I just get an E0F Error but I do not see any mistakes... Can someone take a look at my script and tell me what I'm doing wrong and explain why? Thank you https://code.sololearn.com/cNnamk5O37sV/?ref=app

1st Jan 2020, 4:39 AM
Hawk Strattus
Hawk Strattus - avatar
3 odpowiedzi
+ 4
In the following line there is a pair of parenthesis missing after lower elif inp.lower == "divide": All the rest of your code is running. Its a real nice code!! You should also have a look on your code in terms of “repeated code”, which should be avoided. You need for each operation 2 numbers. And you request these numbers for each of the operations. Try to have only one place where you ask for the input. The same is for the output. Try to find a way to get only one place for output. If you have any further question you are welcome to come back here. I wish you great success, and a happy new year!
1st Jan 2020, 7:32 AM
Lothar
Lothar - avatar
+ 2
Thank you guys for all the help, after fixing the code, I still get E0F errors, which I think is from the multiple inputs in solo learn. Thanks for the challenge lothar
1st Jan 2020, 7:35 AM
Hawk Strattus
Hawk Strattus - avatar
0
Try using string `lower` method, it returns a copy of the string in lowercase format. Example: if inp.lower() == "add": # code to add elif inp.lower() == "subtract": # code to subtract And so on for the rest of the offered operations. The EOF error happens when the program needs an input but there is no more input available. For a code that requires interactive input like this, it's better off to test in console or IDE. SoloLearn playground is not meant for interactive codes. See this code to understand how input works in SoloLearn Code Playground https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
1st Jan 2020, 6:27 AM
Ipang