def check(x):
global username
while True:
if x.isalpha():
break
else:
x = input("Please type your name with letters only!: ")
continue
username = input("? ")
check(username)
print (username)
I have a problem with this code, if the first user input is not alpha, the program will ask for the user's input again until the user inputs the right input by using only alphabetical letters. But when I print the value inside the (username) variable after that, I will get the first user's input even though it is the wrong input and he has already changed it inside the function check():. I have tried to use many solutions, but it did not work. I think it is a problem related to the global variables although I have set the (username) variable as a global variable. If anyone has got any solution for this problem, please help me.