Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # adding fake symbol so last word works as well
- st = "asd)ae aef e'e'e'e asdasd".lower() + "#"
- first_pos = None
- words = []
- alphabet = "qwertyuiopasdfghjklzxcvbnm"
- # iterating through symbols in string
- for i, ch in enumerate(st):
- if ch in alphabet and first_pos is None:
- # memorising first symbol of word
- first_pos = i
- if ch not in alphabet and first_pos is not None:
- # appending word
- words.append(st[first_pos:i])
- # forgetting first symbol of word
- first_pos = None
- print(words)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement