Here is a simple program I'm attempting. The actual searches for capital letters work fine, my main problem is that when I run it, it only asks for the first and last name a second time after wrong input and doesn't do anything else with it. I want it to loop infinitely until isit_uppercase == True
. What am I doing wrong?
import re
def name_get():
global name
name = input("First and last name: ")
return name
name_get()
name_search = re.search(r'(.*) (.*)', name, re.M)
#separates first and last name
firstcap = name_search.group(1)
lastcap = name_search.group(2)
isit_uppercase = re.search(r'[A-Z]', name) #We want this to be true
lowercase_first = re.search(r'\b[A-Z].*', firstcap) #We want this to be true
lowercase_last = re.search(r'\b[A-Z].*', lastcap) #We want this to be true
#testing that the above code is working properly
print(isit_uppercase, "\n", lowercase_first,"\n", lowercase_last)
def main():
if lowercase_first:
print("Please capitalize your first name!")
name_get()
elif lowercase_last:
print("Please capitalize your last name!")
name_get()
elif isit_uppercase == True:
print("That's a nice name!")
else:
print("Please capitalize your first and last name.")
name_get()
main()
while isit_uppercase == False:
main()
I have googled a lot with no luck for answers that apply to this specific situation (that I know of).
Thank you in advance for your ideas!