永发信息网

这段代码错在哪?(python)

答案:2  悬赏:30  手机版
解决时间 2021-01-24 07:30
  • 提问者网友:你独家记忆
  • 2021-01-23 08:57
# Guess My Number Mod 5 tries or bust

import random

print("\nI'm thinking of a number between 1 and 100.")
print("Try to guess it in five tries or less")

my_number = random.randint(1, 100)
guess = int(input("Take a guess, I dare ya "))
tries = 1

while guess != my_number:
if guess > my_number:
print("Try Lower...")
guess = int(input("Go on, Take a guess, I dare ya "))
elif guess < my_number:
print("Try Higher...")
guess = int(input("Go on, Take a guess, I dare ya "))
elif tries == 5:
break
print("u failed")
tries += 1

print("Well done you guessed correctly!The number was", my_number)
print("And it only took you", tries, "tries!\n")

input("\n\nPress the enter key to exit.")
最佳答案
  • 五星知识达人网友:玩家
  • 2021-01-23 10:32
1. 请指明python版本

2. 如果有错,请贴出报错信息
3. 如果不是程序异常,而是有逻辑错误,请说明你希望的逻辑和程序运行时实际的逻辑
全部回答
  • 1楼网友:末日狂欢
  • 2021-01-23 11:05
1. 请指明python版本 2. 如果有错,请贴出报错信息 3. 如果不是程序异常,而是有逻辑错误,请说明你希望的逻辑和程序运行时实际的逻辑
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯