## mkweska

Hello all!

I am sorry to have to waste your time with such an easy problem but I am stuck with some coders block on this one. I know it is definitely an easy fix I just cannot seem to wrap my head around it at the moment... I do feel quite foggy at the moment though...

Here is my code

``````#Ian Olsen
#calculate distance traveled and display each hour.

def main():

#Get MPH car traveled at
speed_traveled = int(input('How many MPH did you travel at? : '))

#Get hours traveled
hours_traveled = int(input('How many hours did you travel? : '))

#start loop and accumlator for hours
print('Hour            Distance Traveled')
print('---------------------------------')
for hour in range(hours_traveled):
total = 0

#math
displaytotal = speed_traveled * hours_traveled
total += displaytotal

print(hour+1, displaytotal, sep='\t\t')

main()
``````

I have it to only display the displaytotal which is the grand total.. I am lost as to how to get it to display the total for each hour.

## mkweska

Getting closer....just need to figure out how to start distance off at the intial speed_traveled

``````#Ian Olsen
#calculate distance traveled and display each hour.

def main():

#Get MPH car traveled at
speed_traveled = int(input('How many MPH did you travel at? : '))

#Get hours traveled
hours_traveled = int(input('How many hours did you travel? : '))

#start loop and accumlator for hours
print('Hour            Distance Traveled')
print('---------------------------------')
for hour in range(hours_traveled):
distance = speed_traveled
#math
distance = speed_traveled * hour

print(hour+1, distance, sep='\t\t')

main()
``````

## mkweska

Alrighty....after an hour of fiddling with the logic I have gotten it to do the math properly... Now I just need to get it to end with the final variable rather than cutting it off. Its ranges 1 through 9

``````#Ian Olsen
#calculate distance traveled and display each hour.
#Get MPH car traveled at
speed = int(input('How many MPH did you travel at? : '))
hours = int(input('How many hours did you travel? : '))

def main():
#start loop
print('Hour            Distance Traveled')
print('---------------------------------')
for hour in range(1, hours):
distance = hour * speed
#math
print(hour, '\t\t', distance)

main()
``````

# Used 80 and 10 for test variables

## mkweska

Already after listening to some mozart to help focus I have came up with ein solution!

``````#Ian Olsen
#calculate distance traveled and display each hour.
#Get MPH car traveled at
speed = int(input('How many MPH did you travel at? : '))
hours = int(input('How many hours did you travel? : '))

def main():
#start loop
print('Hour            Distance Traveled')
print('---------------------------------')
for hour in range(1, hours+1):
distance = hour * speed
#math
print(hour, '\t\t', distance)

main()
``````