Python Forum

Full Version: Program doesnt return beginning
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
num=int(input("age:" ))

if num>18:
    print("old")
else:
   print("young")
When this code is first running there is no problem, but entering second input , print only data value instead condition statement
I do not understand the question. Your code provides no way to enter a second input. You run the program. The program waits for you press the enter key. The program converts whatever you typed into an int. If the int is > 19 the program prints "old", otherwise it prints "young". Execution reaches the end of the program, and the program ends.

Do you want to repeat the code? (get input, print...)? To do that you need some kind of loop (for or while).
how did you run the second time.
The way your code is structured, it will run once then exit program.

In order to continue, you need to create a loop.
Then, if you create a loop, you should also create a condition that will allow you to exit the loop.