我正在学习如何在 while 循环中使用 continue 语句,并将此代码作为练习示例编写。我希望在打印最终消息之前得到一些“本科生”、“研究生”和“博士”的回复。我可以继续完成吗?
print("Welcome to Higher Education U. Please partake in the following roll call.")
name = input("What is your name? ")
level = input("Which program are you in: undergrad, grad, phd or other? ")
while True:
if level == 'undergrad':
print(f"Hi {name}, you are one of the first undergrads.")
continue
elif level == 'grad':
print(f"Hi {name}, you are one of the first grad students.")
continue
elif level == 'phd':
print(f"Hi {name}, you are one of the first phd students.")
continue
else:
print(f"Hi {name}, please consider applying to HEU!")
break
largeQ
相关分类