ACTIVITY 35 / 50
Try as many times as you needReturn a result
Let’s understand
return ends a function and sends a value back to its caller. print only displays a message. Return a calculation with return if the program needs to use its result later.
Listen to the explanation
Example
def add_one(n):
return n + 1
print(add_one(4))Define double(n) to return n * 2. Read a number and print its doubled value.
I need a hint
Use return inside and print(double(...)) outside.
How to find an error
- Read the last line of the error message.
- Find the indicated line. Check quotes, parentheses and indentation.
- Change one thing and run again.
main.py
4 spaces
Your draft stays in this browser.
Result
PythonYour program’s output will appear here. Click Run.
Мой профиль