Problem 103465 · easy · Phase 01 Prerequisites & Setup

Read Down the Columns

nested loops · strings · lists

A secret message was written into a grid row by row, but it must be read down the columns. rows is a list of equal-length strings. Return a list containing one string per column: the first string is the first character of every row (top to bottom), the second is the second character of every row, and so on.

Examples

Input:  rows = ["abc", "def"]
Output: ["ad", "be", "cf"]

Input:  rows = ["x"]
Output: ["x"]

Constraints

  • 0 <= len(rows) <= 50, all rows have the same length between 1 and 50.
  • Return [] when rows is empty.

Goals

  • Swap the roles of the outer and inner loop to read column-wise
  • Build strings character by character
Starting Python…