+ 2
whats wrong with my code?
https://code.sololearn.com/ck0l471qTj21 hi i was tring to build the canculeror acording to the instractions in the python cours. but it does not work and i dont know whats wrong with it
5 Respostas
+ 3
this is right.see it:
https://code.sololearn.com/csMQoDNBB4Y8/?ref=app
+ 2
Hi i was trying to build a calculator according to the instructions in the python course. But it doesn’t work and I have no idea whats wrong with it.
Sorry i can’t python so maybe this will help others to see...
+ 2
First, align the intendation levels - Python is picky on that.
+ 2
yes, the problem is with alignment
elif user_input == "add":
um1 = float(input("Enter a number: "))
num2 = float(input("Enter another number: "))
should be
elif user_input == "add":
um1 = float(input("Enter a number: "))
num2 = float(input("Enter another number: "))
or
elif user_input == "add":
num1 = float(input("Enter a number: "))
num2 = float(input("Enter another number: "))
(notice you made this typo as well of um1)
look at the indentation, the above lines are from 12,13,14.
also, no need of ... the ellipsis, ellipsis comes in consoles of online compilers or idle, maybe you wrote there and copied your code from there.
just focus on the
indentation
and everything will be fine.
Good Luck :)
this was simple code, otherwise I myself have faced the problem while writing classes,
the rule in writing Python is keep track of indentation
+ 2
um1 - > num1 typo