Advertisement
zhongnaomi

look for item in a list and count

Feb 6th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. colours =['white', 'white', 'green', 'purple', 'black', 'white', 'white',
  2. 'black', 'blue',     'purple', 'yellow', 'green', 'white',
  3. 'blue', 'blue', 'green', 'green', 'red', 'black', 'yellow',
  4. 'white', 'blue', 'orange', 'green', 'blue', 'green', 'white',
  5. 'red', 'yellow', 'red', 'green', 'white', 'red', 'white',
  6. 'yellow', 'orange', 'red', 'black', 'green', 'orange', 'purple',
  7. 'blue', 'red', 'red', 'blue', 'purple', 'yellow', 'yellow', 'red',
  8. 'yellow']
  9.  
  10. count = 0
  11.  
  12. for item in colours:
  13.     if item == "blue":
  14.         count += 1
  15.        
  16. print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement