I'm trying to learn Python between self thought of projects relevant to me and utilizing teamtreehouse though it's slow progress.
I'm trying to find a tutorial on how to make a python 3.3.2 for loop run from a value of 0 until the value the user inputs into variable hours. So far I just get an error running this code. I'm not having success finding tutorials that cover this approach.
The below tutorial seems to cover starting at nothing then running through printing out values of lists/dictionariies http://www.python-course.eu/python3_for_loop.php
Same thing with this tutorial http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3/For_Loops
This has got me thinking if it's not possible and instead I need to research/learn other loops?
#//////MAIN PROGRAM START//////
#//////VARIABLE DECLARATION//////
speedMPH=0
timeTraveling=0
hours=1
distanceTraveled=0
#//////VARIABLE DECLARATION//////
#//////USER INPUT FUNCTION//////
def userInput():
speedMPH=int(input("Please provide the speed the vehicle was going in MPH."))
hours=int(input("Please provide the number of hours it has been traveling in hours."))
#////////////////testing variable values correct////////////////
# print(speedMPH)
# print(hours)
# print(distanceTraveled)
#////////////////testing variable values correct////////////////
#//////USER INPUT FUNCTION//////
print('Distance Traveled\t\t\t' + 'Hours')
for i in range(1, hours + 1):
distanceTraveled=0
distanceTraveled = speedMPH * i
print(distanceTraveled, '\t\t\t\t\t', i)
#//////CALLING FUNCTION//////
userInput()
#//////CALLING FUNCTION//////