题目:
goal = 100
while True:
guess = int(input())
if(guess<goal):print("less than expected")
elif(guess>goal):print("larger than expected")
else:print("you win");break
这两个有什么区别呢?第一个代码一次测试中可以多次输入直到猜出100才结束,第二个代码每次调试只要输入一次数据就结束了。
goal = 100
while True:
guess = int(input())
if(guess<goal):print("less than expected")
elif(guess>goal):print("larger than expected")
else:print("you win");
break