Back to questions
JuniorTheoryCommon
What does the program print?
names = ["ann", "bob", "cid"]
scores = [90, 75]
pairs = list(zip(names, scores))
numbered = list(enumerate(names, 1))
print(len(pairs), numbered[-1][0])2 3
- Expecting
3pairs:zipstops at the shortest input and raises no error, so the third name gets no score andpairsholds2tuples. - Expecting the last number to be
2:enumerate(names, 1)starts counting at1, so the three names get1,2and3.
- What does
pairscontain here? - How would you number the names starting from
0?