Menu
Coddy logo textTech

Membership

Part of the Fundamentals section of Coddy's Python journey — lesson 67 of 77.

You can check whether an element is in the a list or not (in, not in):

2 in [1, 2]      # True
3 not in [1, 2]  # True
3 in [1, 2]      # False
challenge icon

Challenge

Easy

Create a program that receives two lists and prints a new list of all elements that are in the first list but NOT in the second list.

Cheat sheet

Check if an element is in a list using:

element in list     # Returns True if element is in the list
element not in list # Returns True if element is not in the list

Try it yourself

# Splits each input string into a list, using commas as separators
lst1 = input().split(",")
lst2 = input().split(",")
# Write your code below
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals