Q:

I dont understand what I typed wrong on def function but it is all correct on Python?

I am currently learning Python and I have problem with def function which I dont know what is the problem?
I am thinking to convert inches to centimeters or opposite,heres the code and error:
def centimeters_to_inches(inches):
    inches = centimeters / 2.54
    return(inches)

print(centimeters_to_inches(100))

error
Traceback (most recent call last):
  File "myfunction.py", line 5, in <module>
    print(centimeters_to_inches(100))
  File "myfunction.py", line 2, in centimeters_to_inches
    inches = centimeters / 2.54
NameError: name 'centimeters' is not defined

A:

In fact there is a mistake in the parameter I guess. The parameter of the function should be centimeters while the return value is inches since it aims to convert centimeters to inches.
def centimeters_to_inches(centimeters):
    inches = centimeters / 2.54
    return inches

print(centimeters_to_inches(100))

The error says that you are using a variable called centimeters that is not defined since it has not been declared (nor as variable nor as a parameter).

