brewersfan1976

ch4-ex5.py

Aug 3rd, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. # takes input from the user and only prints out words
  2. # with a length of 4 or less. Also prints out all substrings of
  3. # the words
  4.  
  5. userInput = raw_input("Please enter a sentence: ")
  6.  
  7. for w in userInput.split():
  8.     length = len(w)
  9.     x = 1
  10.  
  11.     if (len(w) <= 4):
  12.        while (x <= len(w)):
  13.              print w[0:x]
  14.              x = x + 1
Advertisement
Add Comment
Please, Sign In to add comment