import string
import re
r = re.compile(r'[a-zA-Z]+')
name = input("Enter your name: ")
while not r.match(name):
print("Name must be in letters!")
name = input("Enter your name: ")
while len(name) > 12 or len(name) < 3:
print("Name must be between 3 and 12 letters!")
name = input("Enter your name: ")
print("Welcome,",name+".")
This works fine, but if I enter a name that fulfills the first requirement, but not the second and then enter a number, which length is between 3 and 12 characters, it accepts it. For example: first input is xx, then the message: "Name must be between 3 and 12 letters!", second input 1111, which is accepted with: "Welcome, 1111."