首页 新闻 会员 周边 捐助

用Python3版本的编辑猜数游戏程序错误不知道原因求帮助

0
[已解决问题] 解决于 2018-06-18 23:00
 1 inport random
 2 secret = random.randint(1, 99)
 3 guess = 0
 4 tries = 0
 5 print "AHOY!  I'm the Dread pirate Roberts, and i have a cecret!“
 6 print ”It is a number from 1 to 99. I'll give you 6 tries. "
 7 while guess != secret and tries < 6:
 8     guess = input("what's yer guess? “)
 9     if guess < secret:
10         print "Too low, ye scurvy cog!”
11     elif guess > secret:
12         print "Too high, landluber!"
13         
14     tries = tries + 1
15     
16 if guess -- secret:
17     print "Avast! Ye got it! pound my secret, ye did!"
18 else:
19     print "No more guesses! Better luck next time,matey!"
20     print "The secret number was“, secret

Miraclexu的主页 Miraclexu | 菜鸟二级 | 园豆:202
提问于:2018-06-17 21:29
< >
分享
最佳答案
0

import

奖励园豆:5
初新晓 | 菜鸟二级 |园豆:207 | 2018-06-17 22:35

还是不行呢!

import random
secret = random.randint(1, 99)
guess = 0
tries = 0
print "AHOY!  I'm the Dread pirate Roberts, and i have a cecret!“
print ”It is a number from 1 to 99. I'll give you 6 tries. "
while guess != secret and tries < 6:
    guess = input("what's yer guess? “)
    if guess < secret:
        print "Too low, ye scurvy cog!”
    elif guess > secret:
        print "Too high, landluber!"
        
    tries = tries + 1
    
if guess -- secret:
    print "Avast! Ye got it! pound my secret, ye did!"
else:
    print "No more guesses! Better luck next time,matey!"
    print "The secret number was“, secret

 

 

Miraclexu | 园豆:202 (菜鸟二级) | 2018-06-17 22:44

python3输出语句也不对、print()

初新晓 | 园豆:207 (菜鸟二级) | 2018-06-17 22:55

@初新晓: 大神可以用Python3编写一个猜数游戏给我参考一下吗?我改了还是不行呢!

import random
secret = random.randint(1, 99)
guess = 0
tries = 0
print("AHOY! I'm the Dread pirate Roberts, and i have a cecret!“)
print(”It is a number from 1 to 99. I'll give you 6 tries. ")
while guess != secret and tries < 6:
    guess = input("what's yer guess? “)
    if guess < secret:
        print("Too low, ye scurvy cog!”)
    elif guess > secret:
        print("Too high, landluber!")
        
    tries = tries + 1
    
if guess -- secret:
    print("Avast! Ye got it! pound my secret, ye did!")
else:
    print("No more guesses! Better luck next time,matey!")
    print("The secret number was“, secret)

 

Miraclexu | 园豆:202 (菜鸟二级) | 2018-06-18 20:51

@Miraclexu 你双引号一眼看去就有错、那里报错就改那里、报错写的很清楚的

初新晓 | 园豆:207 (菜鸟二级) | 2018-06-18 22:54

@初新晓: 谢谢!

Miraclexu | 园豆:202 (菜鸟二级) | 2018-06-18 22:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册