[Type B] Working with Functions – Chapter 3 Sumita Arora

|
Table of Contents

8. What is wrong with the following function definition?

Python
def addEm(x, y, z):
    return x + y + z
    print("the answer is", x + y + z)

Solution: The print statement is placed after the return statement, which makes it unreachable. Therefore, it won’t be executed.

In short, the print statement is unreachable.

"Spread the light within, illuminate the hearts around you. Sharing is not just an action, but a sacred journey of connecting souls."~ Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *