Why, when I write this code:
pervoe=input("Input first number") vtoroe=input("Input second number") print(pervoe+vtoroe)
the program reads lines 1 and 2, and then closes without reading line 3. Why?
Why, when I write this code:
pervoe=input("Input first number") vtoroe=input("Input second number") print(pervoe+vtoroe)
the program reads lines 1 and 2, and then closes without reading line 3. Why?
As an answer, you get string data, you need to convert them to integers or fractional numbers.
In your case:
pervoe=int(pervoe) #если подразумевается ввод целых чисел или vtoroe=float(vtoroe) #если подразумевается ввод дробных чисел
You can immediately get the user's numerical response by nested method:
pervoe=int(input("Input first number"))
To prevent the program from closing right away, insert the following line:
input("\n\nНажмите Enter чтобы выйти .")
Source: https://ru.stackoverflow.com/questions/398975/
All Articles
cmd
) and run the script already inside. Then, you will always see her output. - eigenein