I have a question about python 3.4.1
So suppose you have a program like this:
name = input("What is your name?")
print("Hi", name ,'!')
So you get:
.>>> What is your name?
So you type in you James and you get back:
.>>> Hi James!
Then after it prints this little message, it automatically resets, and goes back to:
.>>> What is you name?
Thanks for you time! :D
while True:
name = input("What is your name?")
print("Hi", name ,'!')
Use a while loop
You need some condition to break out of the loop:
while True:
name = input("Enter your name or press q to quit")
if name == "q":
break # if user enters `q`, we will end the loop with this break statement
print("Hi", name ,'!') # or else just print the name
A nice tutorial on while loops.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments