Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

How do I print values only when they appear more than once in a list in python

You could make the following adjustments:

c = Counter(seqList[1:])  # slice to ignore first value, Counter IS a dict already 

# Just output counts > 1
for k, v in c.items():
    if v > 1:
        print('-value {} appears multiple times ({} times)'.format(k, v))

# output
-value 1 appears multiple times (2 times)
-value 4 appears multiple times (4 times)

Tags:

Python

List

Related

TypeError: Object(...) is not a function in Vue Can't parse the username to make sure I'm logged in to a website Proper way to return mocked object using pytest.fixture How to call suspend function from Fragment or Activity? Read text file with IAsyncEnumerable Why do some users quote classnames in Perl? What's the difference between *uint and uintptr in Golang? Python TypeError: 'set' object is not subscriptable Support for ES6 imports in ES5 module What's the purpose of the 3rd argument in useReducer? TypeScript 3.7.2 - Support for the experimental syntax 'optionalChaining' isn't currently enabled Difference between usage of Dispatcher IO and Default

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy