ashish chaudhary
Python & AIThe function prints the result I want, but the value stored in result is None.
def double(number):
print(number * 2)
result = double(3)
print("Stored:", result)
CookieSensei starter Q&A · example discussion.
Loading…
The function prints the result I want, but the value stored in result is None.
def double(number):
print(number * 2)
result = double(3)
print("Stored:", result)
CookieSensei starter Q&A · example discussion.
print displays text; return passes a value back to the code that called the function. A function with no explicit return returns None. Return the calculated value when you want to store it, test it or use it in another calculation. You can print the returned result separately.
def double(number):
return number * 2
result = double(3)
print("Stored:", result)
CookieSensei starter Q&A · example discussion.