+ 1

Can Someone fix this code?

It's like control structures > A simple calculator https://code.sololearn.com/cIvLVeGD140E/?ref=app

22nd Feb 2018, 10:25 AM
Hoppip 4.8
Hoppip 4.8 - avatar
16 Respuestas
+ 5
Hoppip 4.8, When declaring variables, you only need '='. Just one equal mark. The proper declarations should be like this: a = 2 b = 1 aa = (a + b) bb = (a - b) cc = (a * b) dd = (a / b)
22nd Feb 2018, 10:34 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 3
the problem is the indentation. And since you remove the while loop, you also have to remove the break statement. Check the code I provided and compare it to your code to see the difference. Indentation is important in Python.
25th Feb 2018, 6:29 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 2
you need to indent your code properly. After else: there should a tab (spaces)
22nd Feb 2018, 10:35 AM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar
+ 2
Here's a working code: https://code.sololearn.com/c6ziJ5pczOp4/?ref=app Aside from what Ravi mentioned, you don't need the while loop in line 7. It causes an infinite loop. then you also have to remove the break statement.
22nd Feb 2018, 10:58 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 2
did you type in capital letters? . ADD is different from add.
25th Feb 2018, 10:05 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
thank you
24th Feb 2018, 3:52 PM
Hoppip 4.8
Hoppip 4.8 - avatar
+ 1
you have to remove the while loop because it is causing an infinite loop.
24th Feb 2018, 11:53 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
the code is working. the input shouldn't have quotation marks. it should be: add not "add"
25th Feb 2018, 8:22 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
I've tried Jonathan's code and everything work well. Just make sure to input add (lowercase).
25th Feb 2018, 10:53 AM
Theofratus
Theofratus - avatar
0
Why it still doeasn't work?
24th Feb 2018, 6:40 PM
Hoppip 4.8
Hoppip 4.8 - avatar
0
ok, but it still doesn't work
25th Feb 2018, 6:17 AM
Hoppip 4.8
Hoppip 4.8 - avatar
0
but your code doesn't work, if I write "add" it print 'addUnknoun input'
25th Feb 2018, 6:40 AM
Hoppip 4.8
Hoppip 4.8 - avatar
0
it says that the 18 line has a problem, add is not definited
25th Feb 2018, 8:43 AM
Hoppip 4.8
Hoppip 4.8 - avatar
0
I wrote add, Add and ADD in user_input, but they are not definited
27th Feb 2018, 6:40 AM
Hoppip 4.8
Hoppip 4.8 - avatar
0
Of course it doesn't work. Look at your code if user_input == "add":
27th Feb 2018, 12:02 PM
Theofratus
Theofratus - avatar
0
I modified, but it still say "name add is not definited"
27th Feb 2018, 4:13 PM
Hoppip 4.8
Hoppip 4.8 - avatar