注册 登录
编程论坛 Python论坛

初学者Python3.2做了一个猜代码小游戏 但是出bug了

Tommy_L 发布于 2015-02-04 11:19, 2686 次点击
只有本站会员才能查看附件,请 登录
这个是应该出现的效果图
只有本站会员才能查看附件,请 登录
这个是我现在出现的bug
还有一个问题就是效果图里的那个4/7 correct不太会做。。。只知道要考虑三种情况
只有本站会员才能查看附件,请 登录
但是不知道下边要怎么做了。。。
4 回复
#2
Tommy_L2015-02-04 11:34
自己修复bug了。。。但是还不知道怎么做那个for循环。。。
#3
Tommy_L2015-02-04 11:59
这是自己已经写得代码
#This is a hacking program
CorrectAnswer='HUNTING'
def displayInstruction(): #Displays instructions
    print('A group of possible passwords will be displayed.')
    print('You must guess the password.You have at most 4 guesses.')
    print('your guess were in exactly the correct location of the passwrod.')
guesses=4
def displaywords(): #Displays words
    for word in words:
        print(word)               
words=['PROVIDE','SETTING','CANTINA','CUTTING','HUNTERS','SURVIVE',\
           'HEARING','HUNTING','REALIZE','NOTHING','OVERLAP','FINDING',\
           'PUTTING']
count=0
displayInstruction()
displaywords()
while guesses>0:
        playsAnswer=input('Enter password '+str(guesses)+' guesses remaining> ')
        if playsAnswer==CorrectAnswer:
                print('User login successful')
                break
        else:
                if guesses>=1:
                        print('Password Incorrect')
                        guesses = guesses - 1
                if guesses==0:
                        print('User login unsuccessful')
#4
ybq1358517992015-05-02 22:17
#5
steven80902016-03-11 15:33
1