(.env) boris@boris-All-Series:~/VOTING$ cat doubleBreak.py
def verifyPresence(extList, z):
# Iterating through all
# lists present in extList:
for subLst in extList:
# Iterating through all the elements
# of each of the nested lists in extList:
for j in subLst:
# Checking if any element in the
# nested list is equal to z:
if j == z:
print('Element found')
break
else:
print(j)
else:
continue
break
# Driver Code:
extList = [[4, 5, 6, 7], [8, 9, 10],[11, 12, 13 , 14, 15]]
z = 12
verifyPresence(extList, z)
(.env) boris@boris-All-Series:~/VOTING$ python3 doubleBreak.py
4
5
6
7
8
9
10
11
Element found
No comments:
Post a Comment