brewersfan1976

ch3-ex1.py

Jul 14th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. # this program take a string and creates a list by each word and counts
  2. # the number of words in the list
  3.  
  4. userInput = raw_input("Please enter a sentence: ")
  5.  
  6. words = 0
  7.  
  8. for w in userInput.split():
  9.     words = words + 1
  10.  
  11. print "There are", words, "words in the list."
Advertisement
Add Comment
Please, Sign In to add comment