Advertisement
thekin

Python - Word counter without len

Oct 5th, 2018 (edited)
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. print("A nice little word counter that does not use the \"len()\" function")
  2. phrase = input("Word: ")
  3.  
  4. letter_count = sum(1 for _ in phrase)
  5.  
  6. print(f"Letters counted: {letter_count}")
  7. input("Press <enter> to exit...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement