Python Forum

Full Version: Defining function error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working through the following question as apart of an assignment:

You have been informed that 1 mile is equivalent to 1.61 kilometres.

Based on the given facts create a function called km with a single parameter called miles, (which you can assume will always be a valid number) and returns the equivalent number of kilometres.

Hint: Use 1.61 value while making the conversion: km = miles * 1.61


I have used the following code for this:

def km(miles):
    kilometers = miles * 1.61
    
    return kilometers
When I submit this for feedback it says that the code is wrong:

Error:
Your result was in the wrong type ---------- - You returned type: float - Expected type: function
I am new to coding in general so any help on this would be really appreciated.
This is not python error. This is result/output from the auto-grading system they use to verify the answer you submit. Check the requirements how you should submit your answer.