def getUsername(errornum):
if errornum == 0:
username = raw_input("Please enter a username: ")
error = checkUsername(username)
if error == 0: return username
else: getUsername(error)
if errornum == 1:
print("You must enter a username.")
getUsername(0)
def checkUsername(username):
if username == "":
return 1
else: return 0
print("Welcome!")
username = getUsername(0)
print("Your username is "+str(username)+".")
When I enter a username, it prints it fine. But if I enter no username, then enter one after the error message is shown, it prints "Your username is None", instead of the one I entered. I'm wondering if this is because I'm having a function calling itself and its losing the return value somehow? Thanks
This post has been edited by Ntwiles: 13 December 2010 - 06:00 PM

New Topic/Question
Reply



MultiQuote




|