Could someone help me fix this please?

This is the place for queries that don't fit in any of the other categories.

Could someone help me fix this please?

Postby Spuddyman » Thu Sep 29, 2016 9:22 am

Code: Select all
user = ""
passWd = ""
confUser = ""
confPassWd = ""
 
def askUser():
    user = input("create your username: ")
    passWd = input("create your password: ")
 
 
# the issue with this running is that it is not giving the user a second go
# at typing in their password IE a chance to confirm their password.
# the code is attempting to check a username and password against the original
# entry, and there is nothing stored to check against. If this went through they
#would not be guessing their username or password at all
#I also need to use Global variables to store the data input, for use across
# my functions, does anyone know how to fix this please? many Thanks.
 
def confLogin():
    confUser = input("re-input your username: ")
    confPassWd = input("re-input your password: ")
    checkPass()
   
def checkPass():
    if confUser == user and confPassWd == passWd:
        login()
    else:
        print ("Your username and/or password was incorrect")
        askUser()
       
def login():
    print ("Welcome "+ user)
    print ("You have successfully logged in!")
    askCom()
   
def askCom():
    command = input("Enter your command: ")
    if command == "log off" or command == "quit":
        username = ""
        password = ""
        print ("You have logged off")
        confLogin()
    else:
        print ("Unknown command")
        askCom()
       
askUser()
confLogin()
Last edited by Yoriz on Thu Sep 29, 2016 11:56 am, edited 1 time in total.
Reason: First post lock. Added code tags.
Spuddyman
 
Posts: 1
Joined: Thu Sep 29, 2016 9:18 am

Re: Could someone help me fix this please?

Postby Kebap » Thu Sep 29, 2016 1:10 pm

Thanks for the code. I assume your question is the one hidden in the code?

# the issue with this running is that it is not giving the user a second go
# at typing in their password IE a chance to confirm their password.
# the code is attempting to check a username and password against the original
# entry, and there is nothing stored to check against. If this went through they
#would not be guessing their username or password at all
#I also need to use Global variables to store the data input, for use across
# my functions, does anyone know how to fix this please? many Thanks.


Do you know how to return values from functions?
Due to the reasons discussed here we are moving to python-forum.net on October 1, 2016.

This forum will be closed. Please create an account at the new site to continue discussion.

IRC://irc.freenode.net/python-forum
Kebap
 
Posts: 689
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 6 guests