+ 12

Why does the calculator not function?

13th Oct 2018, 7:18 AM
🔥EACY🔥
🔥EACY🔥 - avatar
5 Respostas
+ 4
No, I didn't. Look at the indentation. In the first code, I used 4 spaces at the beginning of lines 2 and 4. In the second code, I used random indentation. This is exactly what is wrong with your code. If you look at lines 12 and 16, the elif statements are at different indentation levels. Everything needs to be properly aligned. Yay: if a == b: ____print(b) ____a += 5 elif b != 17: ____pass Nay: if a == b: __print(b) ____a += 5 _elif b != 17: _____pass
13th Oct 2018, 8:42 AM
Anna
Anna - avatar
+ 3
Which calculator?
13th Oct 2018, 7:49 AM
Paul Grasser
Paul Grasser - avatar
+ 3
Because if u mean this one: https://code.sololearn.com/cA7TEOn87bVM/?ref=app It does work. Input in the CP is a bit complicated. Each Input should be a new line, all taken at the beginning.
13th Oct 2018, 7:51 AM
Paul Grasser
Paul Grasser - avatar
+ 3
So I guess this is the code you're talking about: https://code.sololearn.com/cNztNFkpdu59/?ref=app Make sure to use the same indentation levels throughout the entire code. This works: if a == b: do_this() else: do_that() This doesn't work: if a == b: do_this() else: do_that()
13th Oct 2018, 8:39 AM
Anna
Anna - avatar
+ 2
You wrote the same code twice (if a == b:....)
13th Oct 2018, 8:41 AM
🔥EACY🔥
🔥EACY🔥 - avatar