鱼C论坛

 找回密码
 立即注册
查看: 3572|回复: 13

[已解决]python 有人帮忙看看这个代码可以简化一下吗

[复制链接]
发表于 2020-3-31 10:23:07 | 显示全部楼层
  1. import random ; answer = random.randint(1,15) ; time=0 ; rest=5
  2. print("-----I am destiny-----\n你只有5次机会")
  3. temp = input("猜猜我在想1-15中的哪个数字:") ; guess = int(temp)
  4. while guess!=answer and time<5:
  5.     time+=1 ; rest -= 1
  6.     if guess == answer:
  7.         print("。。。\n恭喜你")
  8.     else:
  9.         if guess<answer:
  10.             print("嘿,小了,小了")
  11.         else:
  12.             print("大了,大了")
  13.         print("还有",rest,"次机会")
  14.     temp = input("再猜猜:") ; guess = int(temp)
  15. print("好了不玩了")
复制代码


这样偷工减料 哈哈哈哈哈你们应该看不见
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-9-21 02:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表