+ 1
Code not working
I was experimenting with a little begginers coding and wasn't sure what I did wrong: x = input("Enter number:") Enter number: 5 x*=4 print(x)
6 Answers
+ 10
x is string, you should convert it to integer
x = int(x)
+ 5
you can try this:
x = int(input("Enter number:"))
#Enter number: 5
x*=4
print(x)
input() function does always create a string, regardless what you enter.
+ 4
Ola Michalewska
Option #2:
x = int(input("Enter number:"))
If you comment - "Enter number: 5" was written in the code without the "#" symbol, then by eliminating this error, the output will be: "5555".
đ
#Enter number: 5
x = input("Enter number:")
x*=4
print(x) #Enter number: 5555
+ 4
ola, i took the code to the Playground and saved it. It does work. To make sure that you get the steps done for properly run the code here a brief description. Click on the link below, it will load the code and display it. Press "Run" button. The input window from Playground pops up.
Click in the input area inside the window, you will see the cursor blinking. Now input 5. After this press the "Submit" button. Playground will work a short time and then display the result which is 20.
https://code.sololearn.com/cMZ0mPNqm717/?ref=app
+ 1
I tried writing this code as you suggested, but it didn't work
x = int(input("Enter number:"))
#Enter number: 5
x*=4
print(x)
+ 1
Thank you