|
本帖最后由 栀子花 于 2021-12-3 16:28 编辑
程序运行被标红,不会改,求指教
标红见图片,
运行代码如下:
import random
secret =random.randint(1, 100)
guess =0
tries =0
print("AHOY! I'm the dread pirate roberts, and i have a secret!")
print("it is a number from 1 to 100. i'll give you 6 tries.")
while guess !=(secret and tries < 6:
guess = int(input("whatis yer guess?"))
if guess < secret:
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 secrect, ye did!")
else:
print("no more guesses! better luck next time, matey!")
print("the secret number was", secret)
|
|