|
发表于 2021-4-26 11:22:58
From FishC Mobile
|
显示全部楼层
|阅读模式
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
word=random.randint(1,10)
print("我们来玩个游戏吧!")
guess=input("猜猜我心中在想哪个数字,1到10之间哦^.^")
print(word)
while True:
if guess==word:
print("真聪明,猜对了!")
break
elif guess>word:
print("大了,大了")
elif guess<word:
print("小了,小了")
print("猜错了哦!再来一次")
guess=input("猜猜我心中在想哪个数字,1到10之间哦^.^")
print("游戏结束,你真棒!")
errorTypeError: '>' not supported between instances of 'str' and 'int'
guess=input("猜猜我心中在想哪个数字,1到10之间哦^.^")
input() 函数 默认输入的是 字符
类型转换一下
guess=int(input("猜猜我心中在想哪个数字,1到10之间哦^.^"))
|
|