# My code is executing the passenger summary too soon

## Question:

My train program is working correctly and doing the correct calculations however it is firing the passenger ticket summary information too soon before I have a chance to enter more than one child’s name.

Although the data it lists is not wrong I want the summary of Number of adults number of kids, stop info, count of adult tickets and count of children’s tickets to fire only once right before the totals are given.

``````#This program will calculate all the passengers(adults and kids)that ride the bus from Washingtion to New York
#This program will also calculate the bus rides with stops at Baltimore and Philadelphia

#Function that displays name, class, and date

def main():
passname=None
passchild=None
morepassengers=True
names=list()
childcounts=list()
totals=list()
stops=list()
childprices=list()
totalprices=list()

wash_to_balt_child = 10
wash_to_philly_child = 10
wash_to_ny_child = 15

def welcome():
print("Welcome to Kevin's Travel Service!")

def myname():
print('Written by: Kevin B')
print('Written on date: Feb 26,2023')

def stops_prices():

#Prompt user on where they are stopping at
print("nThe stops for the bus stops at are Baltimore, Philiadelphia, and New York.n")
print('The price from Washington to Baltimore is: \$' + str(wash_to_balt_adult),'for adults, \$'+ str(wash_to_balt_child),'for children.n')

print('The price from Washington to New York is: \$' + str(wash_to_ny_adult),'for adults, \$' + str(wash_to_ny_child),'for children.n')

def passinfo():
validname = False
childcount = ""

# Prompt user on where they are departing bus to
stop = int(input("nnWhere are you traveling to? Please enter 1 for Baltimore, 2 for Philadelphia, or 3 for New York, <Enter> to exit:t"))

# Validate stop
while not validname:
if stop < 1 or stop > 3:
stop = int(input("Invalid number. Please enter 1 for Baltimore, 2 for Philadelphia, or 3 for New York: "))
else:
validname = True

name = input("What is the passenger's name? ")

childcount = int(input("nHow many children? "))
childnames = []
for number in range(childcount):
print("nChild", number+1)
name = input("What is the passenger's name? ")
childnames.append(name)

if stop == 1:
# Calculate the cost for adults going to Baltimore
# Calculate the cost for children going to Baltimore
childprice = childcount * wash_to_balt_child
print('Total cost of childrens tickets: ',childprice)
print('Total cost of all tickets: ',totalprice)

elif stop == 2:
# Calculate the cost for children going to Philadelphia
childprice = childcount * wash_to_philly_child
print('Total cost of childrens tickets: ',childprice)
print('Total cost of all tickets: ',totalprice)

elif stop == 3:
# Calculate the cost for adults going to New York
childprice = childcount * wash_to_ny_child
print('Total cost of childrens tickets: ',childprice)
print('Total cost of all tickets: ',totalprice)

main()
welcome()
print('n')
myname()
print('n')
passinfo()
print('n')
``````

### You should de-indent the code you want to not be inside the loop

You currently say:

``````for number in range(childcount):
print("nChild", number+1)
name = input("What is the passenger's name? ")
childnames.append(name)

``````

Try this:

``````for number in range(childcount):
print("nChild", number+1)
name = input("What is the passenger's name? ")
childnames.append(name)