原程序:
import random
secret = random.randint(1,99)
guess=0
tries=0
print "AHOY! im the dread print Roberts,and i have a secret!"
s a nunber form 1 to 99.i
print "itll give you 6 tries"
s yer guess?")
while guess != secret and tries < 6:
guess =input("what
if guess
print "too low,ye scurvy dog!"
elif guess > secret:
print "too high,landlubber!"
tries = tries + 1
if guess ==secret:
print "avast!ye got it! found my secret,ye did!"
else:
print "no more guesses!better luck next time,matey!"
print "the secret numaber was",secret
F5之后:
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
================================ RESTART ================================
AHOY! i
m the dread print Roberts,and i have a secret!
s a nunber form 1 to 99.i
itll give you 6 tries
s yer guess?50
what
too low,ye scurvy dog!
whats yer guess?90
s yer guess?80
too high,landlubber!
what
too high,landlubber!
whats yer guess?70
s yer guess?60
too high,landlubber!
what
too low,ye scurvy dog!
whats yer guess?75
s yer guess?70
too high,landlubber!
what
too high,landlubber!
what`s yer guess?65
too high,landlubber!
no more guesses!better luck next time,matey!
the secret numaber was 62
为什么**tries < 6:** 但是结果却是50,90,80,70,60,75,70,65共计8次呢?