I want to create a loop who has this sense:
for i in xrange(0,10):
for k in xrange(0,10):
z=k+i
print z
where the output should be
0
2
4
6
8
10
12
14
16
18
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
zipto turn multiple lists (or iterables) into pairwise* tuples:But
zipwill not scale as well asizip(that sth mentioned) on larger sets.zip‘s advantage is that it is a built-in and you don’t have toimport itertools— and whether that is actually an advantage is subjective.*Not just pairwise, but n-wise. The tuples’ length will be the same as the number of iterables you pass in to
zip.