Checking Subset in Python

Checking Subset in Python

Instructor-svgAl-Mamun Sarkar
Mar 24 , 2020

Checking if a set is a subset of another set in python. The following code shows how to find a subset on set in python. This is the solution of the HackerRank Check Subset Python Sets problem.

Code:


T = int( input() )
for x in range(0,T):
	n = int(input())
	A = set(input().split())
	m = int(input())
	B = set(input().split())
	
	if len(A.difference(B)):
		print('False')
	else:
		print('True')

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram