Re: [Tutor] Iterate over multiple objects

2008-10-29 Thread Jerry Hill
On Wed, Oct 29, 2008 at 7:30 AM, W W <[EMAIL PROTECTED]> wrote: > I'm trying to compare two strings because I want to find the difference. Albert pointed you to zip so that you can iterate through the two strings in lockstep. You may also want to investigate the python difflib module in the stand

Re: [Tutor] Iterate over multiple objects

2008-10-29 Thread A.T.Hofkamp
W W wrote: Hi, I'm trying to compare two strings because I want to find the difference. i.e. string1 = "foobar" string2 = "foobzr" is there a simple way to do this with a for loop? This is the method I tried, but it gives me an error: In [14]: for x, y in bar[0], bar[1]: : print x,

Re: [Tutor] Iterate over multiple objects

2008-10-29 Thread W W
On Wed, Oct 29, 2008 at 5:38 AM, A.T.Hofkamp <[EMAIL PROTECTED]> wrote: > > With the zip() function you can merge two sequences into one: > > for x, y in zip(string1, string2): >print x, y > Ah! I *knew* there was a way - I just couldn't remember what it was. Thanks! -Wayne

[Tutor] Iterate over multiple objects

2008-10-29 Thread W W
Hi, I'm trying to compare two strings because I want to find the difference. i.e. string1 = "foobar" string2 = "foobzr" is there a simple way to do this with a for loop? This is the method I tried, but it gives me an error: In [14]: for x, y in bar[0], bar[1]: : print x, y :