The CTP Book

A book for teaching Computational Thinking and Programming skills to people with a background in the Humanities

View on GitHub

Understanding - Beginner, exercise 11

Text

Consider the following Python function:

def i(obj, x):
    if obj and x not in obj:
        return x
    else:
        return obj

What is the result of the execution of i([], 6)?

Solution

[]

Additional material

The runnable Python file is available online. You can run it executing the command python exercise_11.py in a shell.