|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
【求助帖】请及时确认最佳答案,下次提问时可以得到更多关注,问题可以更快解决
代码:
print('------鱼C工作室-------')
print('不妨猜一下小甲鱼心里的数字:')
temp = input(temp)
if guess == 8:
print('你是小甲鱼肚子里的蛔虫吗')
else:
print('猜错啦')
print('游戏结束')
我的运行框
Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
小甲鱼的运行框
Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> ------鱼C工作室-------
不妨猜一下小甲鱼心里的数字:
本帖最后由 柿子饼同学 于 2021-11-23 19:49 编辑
- print('------鱼C工作室-------')
- print('不妨猜一下小甲鱼心里的数字:')
- temp = input('猜一猜甲鱼喜欢的数字吧:')
- guess = int(temp)
- if guess == 8:
- print('你是小甲鱼肚子里的蛔虫吗')
- else:
- print('猜错啦')
- print('游戏结束')
复制代码
写代码要仔细呀
temp = input(temp) 这是错的 , temp 事先没定义 , 而且 input 里面要放字符串
因为 input 的返回值是字符串 , 所以 temp 也是字符串 ,
又因为后面要与数字 8 进行比较 , 所以用 int 函数使 temp 变成一个整数 , 赋值给 guess 之后才能比较
guess 变量你之前没有定义 , 所以也出错了
照着我的代码自己写一遍哦
|
|