Python Practice › List Programs › Program 41

At least one common member

EasyList Programs · 41 of 100

Write a Python program that returns True if two lists have at least one common member.

Advertisement
Input
["a", "b"] and ["c", "b"]
Output
True

Approach

  1. any(x in b for x in a).

Solution

Python
a, b = ["a", "b"], ["c", "b"]print(any(x in b for x in a))
Output
True

Learn the concept

New to this topic? Read the lesson, then come back.

More list programs

← All 100 List Programs

Leave a Comment