selfteaching / selfteaching/selfteaching-python-camp
【自学内容】 请大家看看这个程序问题出在哪里
Open
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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