while 是循环语句,True 在while 后面表示 while 开始循环的条件如:
responses = {}
active = True
while active:
name = input("\nWhat's your name:")
response = input('\nWhich mountain would you like to climb someday?')
responses[name] = response
repeat = input("\nWould you like to let another person respond?(yes/no)")
if repeat == 'no':
active = False
print("\n---Poll Results---")
for name,reponse in responses.items():
print(name + "would you like to climb " + response + ".")
这个while 循环的可以循环的条件是True才行,代码中间那个active = False的时候,while的循环机制就不会被触发。
我也是个Python新手,希望能够帮到你。