selfteaching / selfteaching/selfteaching-python-camp

【自学内容】 请大家看看这个程序问题出在哪里

Open
#2,942 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

随机猜数字,比大小,6次机会

现在问题是比6小那步说是字符串与数值的比较,但是tries有转换成int()了啊,为什么还是提示字符串与数值比较大小

import random

secret=random.randint(1,100)
guess=0
tries=0
guess=int()
tries=int()
print("AHOY!I'm the Dread Pirate Roberts,and I have a secret!")
print("It's a number from 1 to 99,I'll give you 6 tires. ")

while guess != secret and tries <6:
    guess=input("what's your guess?")
    if guess<secret:
        print("TOO low!")
    elif guess>secret:
        print("TOO HIGH!")
    tries +=1

if guess==secret:
    print("You got it!")
else:
    print("NO more guesses~")
    print("The secret number was",+secret)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the Python program from the issue body and inspect the value returned by input() before the comparisons with secret. Confirm the comparisons behave correctly after the input is converted, then verify that the guessing loop reports TOO low or TOO HIGH and allows six attempts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.