I want to be able to interate both list1 = list('asdf') and list2 = list('qwer') at the same time. What is the best approach?
for i, p in list1, list2:
print(i,p)
Where i would be increment list1 and p would be increment list2.
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.
Use
zip(oritertools.izipif the two lists are large):Alternately, if
list1might not be the same length aslist2useizip_longestfromitertools