I am trying to create a loop for python to create a variable of different input values.
I want to input 3 different words into the name variable. This is my code:
name = raw_input("What is your name? ")
if len(name) > 0:
print name
I want to repeat the action from the input till I stop input.
Maybe (although I'm not sure if I understand what you're asking for)
n = 0
while n < 3:
name = raw_input('What is your name?')
if name:
print name
n + =1
The variable name will change each time, keep in mind.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.