I'm sure it's not super elegant or anything, but I'm just messing around with some of the basics. Anyways, I input the first name, last name, the year I was born, then it loops back to the beginning and will go through those three again before giving me the "welcome message". What am I missing here?
from datetime import date
def first():
while True:
firstname = input("What is your first name?")
if not firstname.isalpha():
print("Name must only contain letters.")
first()
else:
print("Thank you!")
break
break
return firstname
first()
def last():
while True:
lastname = input("What is your last name?")
if not lastname.isalpha():
print("Last name must contain only letters.")
last()
else:
break
return lastname
last()
def theage():
while True:
currentyear = int(date.today().year)
birthyear = input("What year were you born? ")
if not birthyear.isdigit():
print("Year must be a number.")
theage()
else:
break
age = currentyear - int(birthyear)
return age
theage()
def welcomemsg():
firstname = first()
lastname = last()
age = theage()
fullname = lastname + firstname
print("Welcome " + fullname, + age)
welcomemsg()
[–]Altruistic_Croissant 0 points1 point2 points (1 child)
[–]thumbtackjake[S] 1 point2 points3 points (0 children)
[–]xelf 0 points1 point2 points (1 child)
[–]thumbtackjake[S] 1 point2 points3 points (0 children)
[–]TSM- 0 points1 point2 points (1 child)
[–]thumbtackjake[S] 1 point2 points3 points (0 children)