This is the problem: Write a program named q1() that prompts the user for the starting and ending distance in Kilometers (km), and an increment value. It should then print the conversion table showing values for Kilometers, Miles (M) and Feet (ft). Each value should be displayed as they are calculated.
this is my code:
print("This program prints a translation table between the Kilometers (km), Miles (M) and Feet (ft) scales.")
start_km = input("Enter the Starting Kilometers (km): ")
start_km = int(start_km)
end_km = input("Enter Ending Kilometers (km): " )
end_km = int(end_km)
increment = input("Increment value: ")
increment = int(increment)
km = start_km
M = km*(.621371)
ft = M*(5280)
print("km", " ", "M", " ", "ft")
print("==========================")
list = ['km', 'M', 'ft']
for i in range(start_km,end_km+1,increment):
km = start_km
M = km*(.621371)
ft = M*(5280)
print( km, " ", M, " ", ft)
my problem is that i am getting a list but it is repeating the input value and not incrementing the calculation. how do i get it to iterate ?
kmtostart_kminside the loop, i.e.km = start_km. You need to increment it...