0
When I run this..It asks something...what to do??
4 Antworten
+ 2
The input() function asks the user for an input. input('6') doesn't make much sense. You can use input("Enter first number"), or simply input(), as Sololearn doesn't display the prompt while taking inputs.
Also, since inputs are treated as strings, it may be a good idea to convert it into an integer or a float, with something like num1=int(input()).
Then in line 6, concatenation between a string and an int is not possible, so you'd have to do
print('The answer is ' + str(num1+num2))
Or simply (note the comma)
print('The answer is ', num1+num2)
That's all about the code. Now you have to understand how input on Sololearn works. Here we have to input everything in the pop up box right after we hit run. We put each new input in new lines. Here it could be something like
12
43
add
Then we press Submit, and that's when the code is executed and the output is shown. Does that make sense? Let me know 😊
+ 1
Yes, we have to input all the stuff at the beginning on Sololearn and some other online interpreters. But if you run it on Python installed in your computer, it should work fine.
0
Thanks
0
Is this only for sololearn??