Skip to content

Commit 2294f2c

Browse files
committed
more examples
1 parent 76ae393 commit 2294f2c

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

defining-functions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,29 @@ variable would be much more difficult. Printing things is fine when you
391391
know that you'll only need to print the result and you'll never need to
392392
assign it to a variable.
393393

394+
So if our function returns a value we can use it like this:
395+
396+
```py
397+
>>> def return_hi():
398+
... return "hi"
399+
...
400+
>>> print(return_hi())
401+
hi
402+
>>>
403+
```
404+
405+
If the function prints instead we can call it and just throw away
406+
the None it returns:
407+
408+
```py
409+
>>> def print_hi():
410+
... print("hi")
411+
...
412+
>>> print_hi()
413+
hi
414+
>>>
415+
```
416+
394417
## Examples
395418

396419
Ask yes/no questions.

0 commit comments

Comments
 (0)