lundi 19 novembre 2018

How do you use a while statement to ask a question until something happens python

print('please answer a few questions to create an account')
usersetup = input('what would you like your username to be ')
for index in range(dl):
    while accounts[index][0] == usersetup:
        usersetup = ('username taken. Please try again')
    if accounts[index][0] == usersetup:
        break   
    psetup = input('What would you like your password to be ')
    accounts.append([usersetup,psetup])
#Setting up account for new users.
    outputFile = 'accounts.data'
    fw = open(outputFile, 'wb')
    pickle.dump(accounts, fw)
    fw.close()
#Storing data by using pickle.
    print('Thank you for signing up, please log in.')

When I run this it skips the while block and moves on how do I fix this?

Aucun commentaire:

Enregistrer un commentaire