我无法完全理解为什么会这样:
while True:
age = int(raw_input("What is your age? "))
if age >= 21:
print "Okay! You are old enough to drink."
break
else:
print "Bzzt! You are not old enough to drink."
有效,但这不起作用:
while False:
age = int(raw_input("What is your age? "))
if age >= 21:
print "Okay! You are old enough to drink."
break
else:
print "Bzzt! You are not old enough to drink."
第二个甚至没有执行。我的主要问题是了解计算机如何读取它以及它正在检查的值。如果这看起来很基本,我很抱歉。我一直在自学 Python,但出现了这个问题,我找不到足够的解释。
提前致谢。