Было бы неплохо использовать вашу основную функцию для управления потоком вашей программы. Кроме того, заставьте ваши функции возвращать значения и сохранять их в переменных в вашей основной программе, таким образом, эти функции вызываются только один раз, а ввод пользователя сохраняется для дальнейшего использования. Я позволил себе переписать ваш код, теперь он должен работать лучше:
# Lists 1-4 are for everyone
list1 = ("Documents: Tickets, passport, itinerary.")
list2 = ("Clothing: Tops, pants, shoes, socks, undergarments.")
list3 = ("Electronics: Chargers, headphones.")
list4 = ('Hygiene: Toothbrush, toothpaste, floss, deodorant, hairbrush.')
# List 5 is for women
list5 = ("Makeup and cosmetics, jewelry, handbag, hair ties, straightener or curling rod.")
# List 6 is for men
list6 = ("Ties, cufflinks, razor, shaving gel, after shave.")
# List 7 for winter
list7 = ("Coat, hat, scarf, boots, warm socks, thermals.")
# List 8 is for fall/spring
list8 = ("Outerwear: Light jacket, cardigan, raincoat.")
# List 9 for summer
list9 = ('Flip flops, sunscreen, hat, bathing suit, sunglasses.')
# function that checks whether the users' trip has been booked or not.
def tripBooked():
booked = input("Have you booked your trip already? Please enter yes or no. ")
if booked == 'no' or booked == 'No':
print('Please return once your trip has been confirmed')
return False
else:
print('Lets get to know you a bit better')
return True
# List generator function
def genderListGenerator():
gender = input('What is your identified gender? Please enter male or female. ')
return gender
def seasonListGenerator():
season = input('What season is it where you are going? Please enter winter, fall, spring, or summer. ')
return season
# Welcome the user
def main():
print('Welcome the Personalized Packing List Generator. '
'In order to generate your list, you will have to provide some information about yourself and your trip. ')
if tripBooked():
finalList = [list1, list2, list3, list4]
gender = genderListGenerator()
if gender in ['male', 'Male']:
finalList.append(list6)
elif gender in ['female', 'Female']:
finalList.append(list5)
season = seasonListGenerator()
if season in ["winter", 'Winter']:
finalList.append(list7)
if season in ["fall", 'Fall', "spring", 'Spring']:
finalList.append(list8)
if season in ["summer", 'Summer']:
finalList.append(list9)
print('Here is what we recommend as basic things to take with you:',)
for l in finalList:
print(l)
if __name__ == "__main__":
main()