0

Is something wrong with the indentation?

while True: print('My Python Calculator..') input('This is just a simple calculator that does basic maths. Press the enter button to proceed to the OPTION MENU...') print('Options :') print('Enter the "+" button to add:') print('Enter the "-" to subtract:') print('Enter the "/" to divide:') print('Enter the "quit" button to exit the program:') user_input=input(' : ') if user_input=="quit": break if user_input=="+": num=float(input('Enter a number: ')) num2=float(input('Enter another number: ')) result=num + num2 print('Your answer is', result) if user_input=="-": num=float(input('Enter a number: ')) num2=float(input('Enter another number: ')) result=num - num2 print('Your answer is', result) if user_input=="/": num=float(input('Enter a number: ')) num2=float(input('Enter another number: ')) result=num / num2 print('Your answer is', result) else: print('Unknown input')

1st Sep 2019, 9:08 AM
Onimisi
Onimisi - avatar
8 Answers
+ 3
while True: print('My Python Calculator..') input('This is just a simple calculator that does basic maths. Press the enter button to proceed to the OPTION MENU...') print('Options :') print('Enter the "+" button to add:') print('Enter the "-" to subtract:') print('Enter the "/" to divide:') print('Enter the "quit" button to exit the program:') user_input=input(' : ') if user_input=="quit": break if user_input=="+": num=float(input('Enter a number: ')) num2=float(input('Enter another number: ')) result=num + num2 print('Your answer is', result) if user_input=="-": num=float(input('Enter a number: ')) num2=float(input('Enter another number: ')) result=num - num2 print('Your answer is', result) if user_input=="/": num=float(input('Enter a number: ')) num2=float(input('Enter another number: ')) result=num / num2 print('Your answer is', result) else: print('Unknown input')
1st Sep 2019, 9:48 AM
Anton Böhler
Anton Böhler - avatar
+ 2
yes
1st Sep 2019, 9:17 AM
Anton Böhler
Anton Böhler - avatar
+ 2
some of the indentation is done with spaces and some with tabs, I just did all in tabs and then it worked ... (there are alot of lines wrong ... 😅)
1st Sep 2019, 12:50 PM
Anton Böhler
Anton Böhler - avatar
+ 1
Can you show me where?
1st Sep 2019, 9:25 AM
Onimisi
Onimisi - avatar
+ 1
Thanks
1st Sep 2019, 10:25 AM
Onimisi
Onimisi - avatar
+ 1
Anton Böhler just to take the fun out of it can you please show me which line in particular in my code has improper indentation? I ran yours snd it works fine but I'm not seeing how it differs from mine. Thanks
1st Sep 2019, 12:42 PM
Onimisi
Onimisi - avatar
+ 1
Lol I'm just fustrated rn
1st Sep 2019, 12:58 PM
Onimisi
Onimisi - avatar
+ 1
Maybe i need materials to read
1st Sep 2019, 12:59 PM
Onimisi
Onimisi - avatar