I was trying to create a signup function which will be prompting user fews information. The code below is partial part of the function. I'm using while loop to prevent any invalid input or specific input to perform other task. Once the input validation is done, I used for loop to check for registered email. However, I'm using recursive function when the registering email has been registered, is there a way that I can avoid the resursive function and put the for loop inside the while loop instead ?
user = [['a','a.gmail.com'],['b','b.gmail.com'],['c','c.gmail.com']]
def signup():
print("\ Enter '0' to return mainpage")
emailAddress = input("Please enter your email address : ")
while True:
if emailAddress == '0':
print('mainpage returned')
signup()
elif emailAddress == '':
emailAddress = input("Please enter your email address : ")
else:
break
# check if email address is registered or not
for item in user:
if emailAddress == item[1]:
print("This Email address has been registered")
signup()
else:
print("email registering:",emailAddress)
signup()
breakout to the lowest block in thesignup().for item in usershould be inside thewhileloop, where the currentbreakstatement is.whileloop when your conditions are satisfied.