[Tutor] Beginner's question: Looping through variable & list simultaneously
Dave Angel
davea at davea.name
Tue Dec 3 16:27:57 CET 2013
On Tue, 03 Dec 2013 13:23:21 +0000, Mark Lawrence
<breamoreboy at yahoo.co.uk> wrote:
> On 03/12/2013 13:11, Dave Angel wrote:
> > On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth
<rafael.knuth at gmail.com>
> >> PopularCountries = ["Brazil", "China", "France", "India",
"Vietnam"]
> > You can zip two iterators together and iterate through the
resultant
> > iterable of tuples.
> > for x, country in zip (range (2009, 2014)):
> > Print (x, country)
> You can't zip one iterator and it's print :)
for x, country in zip ( range (2009,2014), PopularCountries):
print (x, country)
And yes, Rafael, you can zip together any number of iterators this
way.
--
DaveA
More information about the Tutor
mailing list