Course Content
Python Functions Tutorial
Python Functions Tutorial
Single Return Value
A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
The function add_numbers
takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result
and printed to the console.
Note
The join()
function in Python is used to join the elements of an iterable, such as a list, into a single string.
Learn more about the join function here.
Swipe to show code editor
Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:
- You have to use arbitrary arguments because we don't know the number of lists to merge.
- Iterate all lists to merge the strings inside the function body.
- Return the resulting string using
return
keyword.
Thanks for your feedback!
Single Return Value
A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
The function add_numbers
takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result
and printed to the console.
Note
The join()
function in Python is used to join the elements of an iterable, such as a list, into a single string.
Learn more about the join function here.
Swipe to show code editor
Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:
- You have to use arbitrary arguments because we don't know the number of lists to merge.
- Iterate all lists to merge the strings inside the function body.
- Return the resulting string using
return
keyword.
Thanks for your feedback!
Single Return Value
A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
The function add_numbers
takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result
and printed to the console.
Note
The join()
function in Python is used to join the elements of an iterable, such as a list, into a single string.
Learn more about the join function here.
Swipe to show code editor
Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:
- You have to use arbitrary arguments because we don't know the number of lists to merge.
- Iterate all lists to merge the strings inside the function body.
- Return the resulting string using
return
keyword.
Thanks for your feedback!
A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
The function add_numbers
takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result
and printed to the console.
Note
The join()
function in Python is used to join the elements of an iterable, such as a list, into a single string.
Learn more about the join function here.
Swipe to show code editor
Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:
- You have to use arbitrary arguments because we don't know the number of lists to merge.
- Iterate all lists to merge the strings inside the function body.
- Return the resulting string using
return
keyword.