Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #counting occurrences of a given item in a list of strings
- from collections import Counter
- colours =['white', 'white', 'green', 'purple', 'black', 'white', 'white',
- 'black', 'blue', 'purple', 'yellow', 'green', 'white',
- 'blue', 'blue', 'green', 'green', 'red', 'black', 'yellow',
- 'white', 'blue', 'orange', 'green', 'blue', 'green', 'white',
- 'red', 'yellow', 'red', 'green', 'white', 'red', 'white',
- 'yellow', 'orange', 'red', 'black', 'green', 'orange', 'purple',
- 'blue', 'red', 'red', 'blue', 'purple', 'yellow', 'yellow', 'red',
- 'yellow']
- c = Counter(colours)
- print (c[input('What is the colour? ')])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement