list = [[ '1', '2'], [ '1', '2'], [ '1', '2'], ['3','4'], ['3','4'],['3','4'],['3','4']]
I would like to print out print( 'the element [ '1', '2'] repeat 3 times')
CodePudding user response:
Same as with any other element check:
>>> x.count(['1', '2'])
3
You can wrap this up in a function:
def f(v):
print(f'Item "{v}" appears {x.count(v)} times in {x}')