User:Fako Berkers/Firstletter

From XPUB & Lens-Based wiki
< User:Fako Berkers
Revision as of 18:12, 26 April 2011 by Fako Berkers (talk | contribs) (Created page with "<source="python"> text = "He saw the cat before he saw the potato." rsl = "" whtsp = True # saves the first character for char in text: if whtsp: # true if previous was a whi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<source="python"> text = "He saw the cat before he saw the potato." rsl = "" whtsp = True # saves the first character

for char in text:

if whtsp: # true if previous was a whitespace (or first char) whtsp = False rsl += char else: # previous char wasn't whitespace, save whitespace. rsl += ' '

if char == ' ': # check if current was whitespace. whtsp = True

print text print rsl </source>