0

How to solve indentation error in python? Please help me.

27th May 2018, 7:26 AM
Sumit Kumar Sharma
Sumit Kumar Sharma - avatar
5 Respuestas
+ 2
Post the code here.
27th May 2018, 12:29 PM
Mitali
Mitali - avatar
+ 2
# Corrected Version while True: print(" Options ") print("enter 'add' to add two numbers") print("enter 'sub' to add two numbers") print("enter 'multiply' to add two numbers") print("enter 'division' to add two numbers") print("enter 'module' to get reminder of two numbers") print("enter 'quit' to quit the program") user_input=input() if user_input=="quit": break elif user_input=="add": # add some code elif user_input=="sub": # add some code elif user_input=="muliply": # add some code elif user_input=="division": # add some code elif user_input=="module": # add some code else: print(unknown input")
27th May 2018, 2:22 PM
‎ ‏‏‎Anonymous Guy
+ 1
i hope you are talking about your calculator program So, here indentation means spacing Unlike c++, in python white space matters mistakes in your program you wrote the statements in while loop without giving space in the beginning(indentation). correct form would be: while true: print( "Options" ) print("enter 'add' to add two numbers") ^ see the tab, it matters and it should be consistent for all other print statement in the " while loop ". same is applicable for if statement
27th May 2018, 7:46 AM
‎ ‏‏‎Anonymous Guy
+ 1
oky thanks sreejith
27th May 2018, 2:26 PM
Sumit Kumar Sharma
Sumit Kumar Sharma - avatar
0
while true: print(" Options ") print("enter 'add' to add two numbers") print("enter 'sub' to add two numbers") print("enter 'multiply' to add two numbers") print("enter 'division' to add two numbers") print("enter 'module' to get reminder of two numbers") print("enter 'quit' to quit the program") user_input=input(:) if user_input=="quit": break elif user_input=="add": elif user_input=="sub": elif user_input=="muliply": elif user_input=="division": elif user_input=="module": elif print(unknown input")
27th May 2018, 12:46 PM
Sumit Kumar Sharma
Sumit Kumar Sharma - avatar