Reputation: 23
This is a program that converts kilometers to miles however, every time I run it there is no line asking for an input, as it is supposed to, instead it is always blank.
Here is the code:
KILOMETERS_TO_MILES =float(0.6214)
def main():
Distance = input("please input the distance in kilometers to wish to convert:"))
showMiles(Distance)
def showmiles(Distance):
miles = Distance * KILOMETERS_TO_MILES
print=("Conversion of ", Distance,"kilometers to miles: ", miles, "miles")
main()
Upvotes: 1
Views: 4038
Reputation: 102
Looks like part of the problem comes from your third line. I have noticed you have two closing brackets '))' yet you only have one opeining '('. '..
Upvotes: 0
Reputation: 577
This should work:
KILOMETERS_TO_MILES = 0.621371
def show_miles(Distance):
miles = Distance * KILOMETERS_TO_MILES
print('Conversion of {} kilometers to miles: {} miles'.format(Distance, miles))
def main():
Distance = float(input("please input the distance in kilometers you wish to convert: "))
show_miles(Distance)
main()
Your original code had several problems:
KILOMETERS_TO_MILES =float(0.6214)
def main():
# You have an extra closing ')' on the next line
Distance = input("please input the distance in kilometers to wish to convert: "))
showMiles(Distance) # this showMiles has an upper case 'M'
def showmiles(Distance): # this showmiles has a lower case 'm'
miles = Distance * KILOMETERS_TO_MILES
# You have an = sign on the next line that shouldn't be there
print=("Conversion of ", Distance,"kilometers to miles: ", miles, "miles")
main()
Upvotes: 2