[Tutor] Difficult loop?
bgailer at gmail.com
Thu Oct 16 17:41:52 CEST 2008
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()
Chapel Hill NC
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?
More information about the Tutor