Мой профиль
ACTIVITY 35 / 50

Return a result

Try as many times as you need

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))
YOUR MISSION

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
  1. Read the last line of the error message.
  2. Find the indicated line. Check quotes, parentheses and indentation.
  3. Change one thing and run again.

main.py

4 spaces

Your draft stays in this browser.

Result

Python
Your program’s output will appear here. Click Run.