+ 1
Why wonât this work
I tried making a simple calculator but the indents are acting weird https://code.sololearn.com/cog7gIBHnP2x/?ref=app
15 Respostas
+ 8
In the app, we need to input everything "at once":
add
4
5
When asked to input, separate the 3 required inputs by enter
+ 7
You forgot to indent one line: b=input().
Also, to make your calculations work, you would also have to make real numbers from your input, for example:
b = float(input())
+ 3
Indent line 6 (b=...), then the code runs. :)
And remember to convert the input numbers to float or int, because by now, your code only pastes the two input numbers together
+ 3
Just as Lisa has identified the problem Videomaker yt , in Sololearn, the input has to be inserted all at once.
On that topic, hereâs another approach of a very simple calculator:
https://code.sololearn.com/cW6rrjRn5b6O/?ref=app
+ 3
You can enter input in one line by using split function
+ 3
I found another problem in your code. No matter what you write in the first input, the if statement (if a=="add" or "addition" or "+":) will always be true.
Solution:
if a=="add" or a=="addition" or a=="+":
+ 2
Just tried your code, works perfectly...
Did you run it in the app?
+ 2
so just group all the inputs together?
+ 2
Yes, each line is for one of the 3 inputs you used (in SL app)
When you run it on a your computer, there will be one input window for each
+ 2
I think I do not understand your question :)
You do not have to group or work around anything, the code runs as it should.
At your one computer, python would go through the script line by line and first ask for input a, than b, then c
In SL we just cannot go through it "step by step", there will always be this single input window in which we have to input everything and submit.
+ 2
I donât particularly see the error, but instead of print, enter immediately in input.
Example: a = float (input ("Enter the first number:"))
b = float (input ("Enter the second number: "))
0
yes
0
k well ill try to work arount it
0
wait is it the inputs you have to group together or the varibles
- 1
that will be a problem in the future