Python program to get input from the user using a while loop and print it until 0 is not pressed
In this program we are going to see how to take input from user using while loop and print it until the user pressed 0.
To take input from user we use input() method.
var_name = input()
Program code –
end=False #declare a boolean variable
i=0
while(not end):
num=int(input("Enter Number :")) #getting input form user
print(num) #display the input
if num==0:
print("You enter 0 program terminated")
end=True #condition true then assign boolean value to True
i+=1 #increment the value of i by 1
Output –