Advertisement
Guest User

Untitled

a guest
Nov 14th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. # adding fake symbol so last word works as well
  2. st = "asd)ae aef e'e'e'e asdasd".lower() + "#"
  3.  
  4. first_pos = None
  5. words = []
  6. alphabet = "qwertyuiopasdfghjklzxcvbnm"
  7.  
  8. # iterating through symbols in string
  9. for i, ch in enumerate(st):
  10.     if ch in alphabet and first_pos is None:
  11.         # memorising first symbol of word
  12.         first_pos = i
  13.     if ch not in alphabet and first_pos is not None:
  14.         # appending word
  15.         words.append(st[first_pos:i])
  16.         # forgetting first symbol of word
  17.         first_pos = None
  18. print(words)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement