Functions can return a value using the return keyword:
def add(a, b):
return a + b
result = add(3, 5)
print(result) # 8
The return statement sends a value back to where the function was called. Without return, a function returns None.
📋 Instructions
Create a function called `fortune_cookie` that:
1. Has a list of at least 5 fortune messages
2. Uses `random.choice()` to pick a random one
3. Returns the fortune
Then call it and print the result:
```python
print(fortune_cookie())
```
Since it's random, any output is accepted!
Fill the fortunes list, then return random.choice(fortunes). You've got this — take it step by step!
⚠️ Try solving it yourself first — you'll learn more!
def add(a, b):
return a + b
result = add(3, 5)
print(result) # 8