Advertisement
furas

Python - count char

May 21st, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. result = 0
  2.  
  3. text = str(list(range(101)))
  4.  
  5. for char in text:
  6.     if char == "7":
  7.         result += 1
  8.  
  9. print('result:', result)        
  10.  
  11. # or
  12.  
  13. text = str(list(range(101)))
  14. result = text.count("7")
  15. print('result:', result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement