I just can't find others with the same problem. Im sure they exist but im not having luck and this is my very first time learning a language. My try/except works when i enter the wrong type of value. However, it does not work when i enter the correct type of value. I've read my text and searched vidz. I just need a full picture of how to use try/except within the function im using.
def convert_distance():
miles = int(input("Enter amount of miles driven: "))
kilometers = miles * 1.609
print(f"At {miles} miles, your distance in kilometers is: {kilometers}")
try:
print(miles = int(input("Enter amount of miles driven: ")))
except ValueError:
print("That is not a number. Please enter a number")
convert_distance()
The error i receive occurs at line 6 and states
TypeError: 'miles is an invalid keyword argument for print()
printfunction does not have a keyword parameter calledmiles.