python

您所在的位置:网站首页 猜数字游戏代码python python

python

2023-03-23 02:56| 来源: 网络整理| 查看: 265

此问题在此处已有答案:

Determine whether integer is between two other integers(16个答案)Asking the user for input until they give a valid response(22个答案)3天前关闭。这是我的准则:

answer = input("Player 1 , Please enter your number: (1 - 100) \n") answer = int(answer) is_correct = False count = 0 while count < 10 and is_correct == False: guess = int(input("Player 2 Please enter you guees: \n")) count = count + 1 if guess == answer: print("Player 2 You won!") is_correct = True elif guess < answer: print("Player 2 your number is smaller thean the answer !") elif guess > answer: print("Player 2 your number is greater than the answer !") if is_correct == False: print("Player 2 You Lost :(")

你好,我试图写一个猜测数字的游戏,但有一个错误,这里有人可以输入一个数字大于100和小于0,但数字应该在0和100之间,我该如何修复它?



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3