> def lowest(s1,s2):
> s = ""
> for c1,c2 in [x for x in zip(s1,s2)]:
> s += lowerChar(c1,c2)
> return s
>
> but it's hardly any more elegant than using a loop counter, and I'm
> guessing it's performance is a lot worse - I assume that the zip
> operation is extra work?
>
> Iain
> def lowest(s1,s2):
> s = ""
> for i in xrange(len(s1)):
> s += lowerChar(s1[i],s2[i])
> return s
>
> this seems unpythonic, compared to something like:
>
> def lowest(s1,s2):
> s = ""
> for c1,c2 in s1,s2:
> s += lowerChar(c1,c2)
> return s
If I understa
Iain King <[EMAIL PROTECTED]> wrote:
...
> This works:
>
> def lowest(s1,s2):
> s = ""
> for c1,c2 in [x for x in zip(s1,s2)]:
> s += lowerChar(c1,c2)
> return s
>
> but it's hardly any more elegant than using a loop counter, and I'm
> guessing it's performance is a lot wor
Iain King si รจ profuso/a a scrivere su comp.lang.python tutte queste
elucubrazioni:
[cut]
I think you should take a look at the zip() function.
You can use for with it like this:
for elem1, elem2, elem3 in zip(list1, list2, list3):
--
Alan Franzoni <[EMAIL PROTECTED]>
-
Togli .xyz dal
When I loop over one list I use:
for item in items:
print item
but often I want to loop through two lists at once, and I've been doing
this like I would in any other language - creating an index counter and
incrementing it.
For example, (completely arbitrary), I have two strings of the same
l