0
Why my program returning ans with none.
def function(celsius): celsius=float(input()) fahrenheit= 1.8 *celsius + 32 print(fahrenheit) print(function (36))
4 Réponses
+ 7
In Python any function or method that does not explicitly return a value will by default return None. Since function() does not explicitly return anything then None is returned from the call to function().
Try this instead;
def func(celsius):
return float(celsius) * 1.8 + 32
print(func(36))
+ 5
Your function doesn't return any value to calling print function. So none will be printed
+ 1
It is answering with "none" because you have no return value in your defined function.
You have to do this.
def function():
celsius=float(input())
fahrenheit= 1.8 *celsius + 32
return fahrenheit
print(function())
https://code.sololearn.com/ciFuk1ozcV64/?ref=app
+ 1
Ty it cleared my concept as well as my problem