-
Notifications
You must be signed in to change notification settings - Fork 0
Chapter 7
Jarlin Almanzar edited this page Nov 21, 2019
·
3 revisions
The function pauses your program and waits for the user to enter some text. Once it retrieves the input, it assigns it to a variable.
Python interprets Input values as a string
height = input("How tall are you, in inches: ")
height = int(height)
if height > 48:
print("You are tall enough")
else:
print("\n You'll be able to ride when you're a little older.")
A loop that runs as long as the condition is true.
curr_num = 1
while curr_num <= 5:
print(curr_num)
curr_num+=1
prompt = "Tell me something, and I will repeat it back to you."
prompt += "\n Enter 'quit' to end the program."
msg = ""
while msg != 'quit':
msg=input(prompt)
print(msg)
active = True
while active:
msg = input(prompt)
if msg == 'quit':
active = False
else:
print(msg)
while True:
msg = input(prompt)
if msg == 'quit':
break
else:
print(msg)