Python Practice › Set Programs › Program 5
Is an element in a set?
Write a Python program to check whether an element is in a set.
Input
{2, 4, 6}, check 4 and 5Output
True False
Approach
inis very fast on sets.
Solution
s = {2, 4, 6}print(4 in s, 5 in s)Output
True False
Learn the concept
New to this topic? Read the lesson, then come back.