[Tutor] loop question
Gregor Lingl
glingl@aon.at
Mon, 12 Aug 2002 21:40:26 +0200
Kyle Babich schrieb:
>####################
>sigs={"sig11":"bakoeaeweeodvddyeo","sig12":"lchlsrhrgdiiebzr"}
>i = 0
>for i in sigs:
> i = int(i)
> print sigs["sig11"][i] + sigs["sig12"][i]
> i = i + 1
>####################
>
>I know the problem is my loop and the i, I just don't know why it is a
>problem or how to fix it.
>
>Thank you,
>--
>Kyle
>
>
We could try this:
>>> sig1, sig2 = "bakoeaeweeodvddyeo","lchlsrhrgdiiebzr"
>>> ''.join(map(''.join, zip(sig1,sig2)))
'blackholesarehwregedoidivedbdzyr'
Oh! Something went wrong, and we don't know what it is ...
You may hav a look at
http://www.python.org/doc/current/lib/built-in-funcs.html for zip and at
http://www.python.org/doc/current/lib/string-methods.html for join
Sorry, that I haven't got the time to explain this at the moment,
I'm already too much distracted from my work.
Have fun!
Gregor