擅长:python、mysql、java
<p>尝试修改<code>main</code>函数:</p>
<pre><code>def main():
correctNum = randomNum()
guess = userGuess()
high = low = 0 # nifty way to assign the same integer to multiple variables
while guess != correctNum: # repeat until guess is correct
if guess > correctNum:
print('That guess is too high!')
high = high + 1
else:
print('That guess is too low')
low = low + 1
print('Try again!')
guess=userGuess()
print('You win!')
# the outcome of the game:
print('Guesses too high:', high)
print('Guesses too low:',low)
print('Thank you for playing!')
</code></pre>
<p>另外,要小心使用<code>random.randint(0,9)</code>:这将给出一个介于0-9之间的数字(包括0和9,但绝不是10)</p>
<p>您想做^{cd3>}</p>