I am asking for an input from the user and it has to be a single character alphabet.
I tried this code.
ask = ''
while len(ask) != 1 and ask.isalpha() != True:
ask = input(message).upper()
But this accepts any single number digit to break out of the while loop. I don't understand why.
I checked the ask.isalpha() on that single number and that returns False. So why does it break out of the loop.
Sorry for this question. This is very naïve but I couldn't find an answer.
Thank you.
Edit: Added the whole code.
==instead of!=with the second part of condition. also, consider usingdo.. whileloop to allow the first input.==doesn't work for me. The loop doesn't even start and there's no prompt for use input after changing to==.askfails to satisfy the loop criteria. setaskto some default value sayaor usedo.. whileloop as suggested.do.. whileloop. stackoverflow.com/a/65840480/5147259 should solve your problem.