Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def askPersonalInfo():
- while True:
- firstName = input("Input your first name: \t")
- lastName = input("Input your last name: \t")
- yearsBirth = input("Input your year of birth: \t")
- gender = input("Input your gender (M, F): \t")
- if firstName == "" or lastName == "" or not yearsBirth.isdigit() or gender not in ("F", "M"):
- print("Wrong data! Please enter valid information.")
- else:
- return firstName, lastName, yearsBirth, gender
- def askHobbies():
- hobbyList = []
- hobbyInd = 1
- while True:
- hobbyName = input(f"Name of hobby {hobbyInd} (or type 'end' to finish): ")
- if hobbyName.lower() == 'end':
- break
- elif hobbyName == "":
- print("Hobby name cannot be empty.")
- else:
- hobbyList.append(hobbyName)
- hobbyInd += 1
- return hobbyList
- # Main program flow
- personal_info = askPersonalInfo()
- hobbies = askHobbies()
- print("\nPersonal Information:")
- print("First Name:", personal_info[0])
- print("Last Name:", personal_info[1])
- print("Year of Birth:", personal_info[2])
- print("Gender:", personal_info[3])
- print("\nHobbies:")
- for i, hobby in enumerate(hobbies, start=1):
- print(f"{i}. {hobby}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement