I just can't leave well enough alone. Down to 14 lines.
More names, less magic numbers.
word = "Almuta$r~id"
window = position = 5
shortAndOmit = "aiou+~"
rest = "_" * window + "".join(letter for letter in word
if letter not in shortAndOmit) + "_" * window
word = iter(word + "+")
for letter in word:
while letter not in shortAndOmit:
position += 1
print rest[position-window:position+window+1] + "_"
letter = word.next()
if letter in shortAndOmit[:4]:
print rest[position-window:position+window+1] + letter
elif letter == "~":
print rest[position-window:position+window+1] + "~" + word.next()
--
Bob Gailer
Chapel Hill NC
919-636-4239
When we take the time to be aware of our feelings and
needs we have more satisfying interactions with others.
Nonviolent Communication provides tools for this awareness.
As a coach and trainer I can assist you in learning this process.
What is YOUR biggest relationship challenge?
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor