In your function -
def miles_to_km_converter (ans):
ans = input('please enter amount of miles you wish to convert:')
print (('you have entered:') + str(ans) + ' miles')
return int(ans)*1.6
m == ans # let's call this line 1
Before line 1 you have made a return call. This call stops the the execution, returns what you want to return and exits the function. After return, nothing gets executed. See here
Also, on line 1, what we are doing is comparing m with ans. This says -
check if ans is equal to a
See python comparison operators
What I think you want is something like this -
def miles_to_km_converter():
ans = input('please enter amount of miles you wish to convert:')
print (('you have entered:') + str(ans) + ' miles')
return int(ans)*1.6
a = miles_to_km_converter()
print ('The conversion equals: ', str(round(a, 3)) + ' km')
Why don't we need parameter to be passed to this function?
Our function miles_to_km_converter
does not need a variable to be passed to it from rest of the function. The purpose of our function is
take input -> convert it -> return it
But if we had a situation where we wanted to pass a variable from the rest of the script to the function, we would need a parameter. Read here
For example -
def miles_to_km_converter (ans):
print (('you have entered:') + str(ans) + ' miles')
return int(ans)*1.6
ans = input('please enter amount of miles you wish to convert:')
# Now our variable `ans` is not accessible to the function
# We need to explicitly pass it like -
a = miles_to_km_converter (ans)
# And then we'll print it
print ('The conversion equals: ', str(round(a, 3)) + ' km')
I hope this answers your question