ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
m = ['abc', 'def']
print([''.join(t) for t in zip(*m)])
  1. A. ['ae', 'bd', 'cf']
  2. B. ['ad', 'be', 'cf']
  3. C. ['abc', 'def']
  4. D. ['ad', 'eb', 'cf']

Correct answer: B. ['ad', 'be', 'cf']

zip(*m) takes the columns of the list of strings. The first column is a and d, the second is b and e, and the third is c and f.

More Python Programming questions

Exams that ask this topic