What happens if we write to consecutive input statement in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What happens if we write to consecutive input statement in python

So I was writing a program in which I unknowingly wrote, input(input()) ,instead of int(input()) And rather then reporting an error it just took the input and returned the same value. So by some chance does consecutive input statement work as first input and print or returns the value.

7th Dec 2022, 1:45 PM
Lev
1 Answer
+ 5
It will get input twice. The inner input() executes first. It returns a string. Next, the outer input() uses that string and prints it as its prompt string. The final return value comes from the outer input().
7th Dec 2022, 2:00 PM
Brian
Brian - avatar