silly idea - interesting problem

scott smarsh at hotmail.com
Sun Oct 21 06:02:10 CEST 2001


Stefan Antoni wrote:
> 
> i got a silly idea about a small script which takes to strings (lets say
> "test" and "dust") and mixes them to "tdeusstt".
> i tried to code it because i thought it would be easy, but now i cannot
> find out _how_ to do it ;)
> 
> i tried to "list()" the string and mix the items. but ...
> 
> Anybody has a hint or even a solution?
> 

Here's a back to basics solution:

firstWord = 'test'
secondWord = 'dust'
i = 0
while i < len(firstWord):
    print firstWord[i], secondWord[i],
    i = i+1

P.S.: Remember when Python used to differentiate itself from line noise
(sorry, I meant Perl) with a philosophy that went something like
"There's only one right way to do it."?

-- 
Colorless green ideas sleep furiously. 
     Chomsky



More information about the Python-list mailing list