非常感谢第二眼看到这段代码因某种原因它永远不会通过输入函数。所以其他块不运行..
#!/usr/bin/env python
import random
# import pdb ; pdb.set_trace()
def main():
print('_' * 40)
print(' Guessing Game. ')
print('_' * 40)
print()
print("guess a number between 1 & 100")
ranNum = random.randint(1, 100)
found = False
while not found:
guess = int(input('please enter a guess:\n'))
if guess == ranNum:
print('you win!')
found = True
elif guess > ranNum:
print('guess lower\n')
else:
print('guess higher')
if __name__ == "__main__":
main()
答案 0 :(得分:1)
谢谢你所有问题都是块的缩进。
while not found:
guess = int(input('please enter a guess:\n'))
if guess == ranNum:
print('you win!')
found = True
elif guess > ranNum:
print('guess lower\n')
else:
print('guess higher'
答案 1 :(得分:0)
放
if guess == ranNum:
print('you win!')
found = True
elif guess > ranNum:
print('guess lower\n')
else:
print('guess higher')
<{1>}循环中的