PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# It is an example on the return keyword for python
def my_func(name):
sentence = 'Hello, ' + name + '.'
return sentence
your_name = 'pink skin'
res = my_func(your_name)
print(res)
print(my_func(your_name)) # same as print(res)
# Added in 2023-10-30
# 2nd Example
print('\nIf the function WITHOUT return')
# This is what will happen if return keyword is missing
def my_func2(name):
sentence = f'Hello, {name}.'
#return sentence
my_name = 'red shirt'
print(my_func2(my_name))
# 3rd Example
print('\nIf the return keyword is in the middle of a function')
def my_func3(name):
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run