-1

There is a code like below :

L=[]
element = input().split()
    L.append(element)

If I input some elements, how could I find the same elements?

like

[['Jason', '100'],['Kevin', '50'],['Petty', '70'],['Jason', '100']]

and how could the python remind me there is 2 or more['Jason', '100'] in the list when I input?

Thank you!

NIkola87
  • 17
  • 5
  • Some ideas here: https://stackoverflow.com/questions/9835762/how-do-i-find-the-duplicates-in-a-list-and-create-another-list-with-them – jarmod Nov 13 '20 at 02:01
  • Does this answer your question? [How can I count the occurrences of a list item?](https://stackoverflow.com/questions/2600191/how-can-i-count-the-occurrences-of-a-list-item) – whackamadoodle3000 Nov 13 '20 at 02:10

1 Answers1

0

Use .count():

L = [['Jason', '100'],['Kevin', '50'],['Petty', '70'],['Jason', '100']]
print(L.count(['Jason','100']))
if L.count(['Jason','100']) >= 2:
  print("2 or More than 2")
else:
  print("Lesser")
Wasif
  • 14,755
  • 3
  • 14
  • 34
  • Thank you but you maybe misunderstand what I means. ['Jason', '100'] and others are inputted elements so L.count(['Jason','100']) cannot be run. – NIkola87 Nov 13 '20 at 02:10