⊗pyPmStLn 109 of 208 menu

Length of a set in Python

The length of a set can be found using the function len:

st = {'a', 'b', 'c', 'd'} print(len(st)) # 4

Given a set:

st = {'x', 1, 'y', 2, 'z', 3, 'w'}

Find out the number of elements in it.

Given a set:

st = {1, 2, 3, 4, 2, 1}

Find out the number of elements in it.

cskadehubn