daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # U05_Ex09_WordCount.py
  2. #
  3. #  Author: Bill Montana
  4. #  Course: Coding for OOP
  5. # Section: A3
  6. #    Date: 11 Oct 2017
  7. #     IDE: PyCharm Community Edition
  8. #
  9. # Assignment Info
  10. #   Exercise: 9
  11. #     Source: Python Programming
  12. #    Chapter: 5
  13. #
  14. # Program Description
  15. #   Counts the number of words in a sentence entered by the user
  16. #
  17. # Algorithm (pseudocode)
  18. #   Print intro
  19. #   Get sentence from user
  20. #   Count words with len(str.split(' '))
  21. #   Print word count
  22.  
  23.  
  24. def main():
  25.     #   Print intro
  26.     print('This program counts the number of words in a sentence entered by the user.')
  27.  
  28.     #   Get sentence from user
  29.     inputStr = input('Please enter a sentence: ')
  30.  
  31.     #   Count words with len(str.split(' '))
  32.     wordCount = len(inputStr.split(' '))
  33.  
  34.     #   Print word count
  35.     print('Word count: {0}'.format(wordCount))
  36.  
  37. main()
RAW Paste Data
Top