#运行结果
Username:a
Full name: Albert Einstein
location: Princeton
Username:b
Full name: Marie Curie
location: Paris
第7章 用户输入 while
#函数input()让程序暂停运行,等待用户输入文本,python将获取的输入存在变量里#input()将输入视为字符串 int()将输入视为数值
name =input("Please enter your name: ")
prompt ="can you tell me more information?"
prompt +="\nHow tall are you, in inches? "
height =int(input(prompt))print(name)if height >35:print("you are very tall!")
#用while在列表之间移动元素
unconfirmed_users =['a','b','c']
confirmed_users =[]while unconfirmed_users:
current_user = unconfirmed_users.pop()print("verifying user: "+ current_user.title())
confirmed_users.append(current_user)print("\nThe following users have been confirmed:")for confirmed_user in confirmed_users:print(confirmed_user.title())
#运行结果
verifying user: C
verifying user: B
verifying user: A
The following users have been confirmed:
C
B
A