I am trying to loop back to the beginning of this code after it is done. After option 'C' is pressed, the program should end, (which I am also struggling with). But I want the program to loop to the beginning unless C is pressed. If 'A' or 'B' is pressed, the program should ask the user to enter an option again. This question is different as it has a specific example. I tried looking on Stack Overflow and found similar questions and tried them, but none of them worked out? Not sure why
#input your full name
def startagain():
firstName=raw_input("Enter your first name: ")
middleName=raw_input("Enter your middle name: ")
lastName=raw_input("Enter your last name: ")
#select what option you want.
options=str(raw_input("Type 'A' for printing the length of your name,
'B' for printing your initials and 'C' to exit"))
#prints first, middle and last name
if (options == "A" or options == "a"):
print firstName + " " + middleName + " " + lastName
#prints your initials
elif (options == "B" or options == "b"):
print firstName[0] + "." + middleName[0] + "." + lastName[0] + "."
#exit
elif (options == "C" or options == "c"):
exit()
print ("OK, bye!")
#invalid selection
else:
print "Invalid selection. Please select A, B, or C."
if options == "A" or options == "B":
startagain()
thanks in advance :)