Advertisement
nanokatka

strings-task4

Feb 13th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. """
  2. 4. Create a program which gets a text string from input and prints out its length.
  3. DO NOT use len() function and collections.
  4. 4.1. The same task but also ignore “white symbols” while counting length.
  5.  
  6. """
  7.  
  8. text=input("write text here:")
  9. count=0
  10. for letter in text:
  11. count=count+1
  12. print("first method (with white spaces) gives number of letters:" ,count)
  13.  
  14. count=0
  15. for letter in text:
  16. if letter == ' ':
  17. continue
  18. else:
  19. count = count+1
  20. print("second method (without white spaces) gives number of letters:" ,count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement