Apr-11-2024, 05:44 PM
Quote:I believe, in Britain, it is customary to write ones name with a capital letter at the beginning.You can use lower() for the comparison without changing the entered name.
It makes more sense to use set operations for this problem.
from string import ascii_lowercase alphi = set(ascii_lowercase + ' ') def enter_name(): while True: name = input("What is the student's name?\n").lower() if len(set(name.lower()) - alphi) == 0: return name print( f"{name} contains characters that are not part of the English alphabet!!\n" "Please enter a valid name!!\n" ) print(enter_name())