how to make a while input code example
Example 1: how to take input until a condition is satisfied in python
while True:
try:
age = int(input("Please enter your age: "))
except ValueError:
print("Sorry, I didn't understand that.")
continue
else:
break
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
Example 2: how to make inputs in a loop in python
for i in range(1,6):
globals()['string%s' % i] = input("Enter something: ")
print(string3)