QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 36

After `rows = [[0]] * 3` and `rows[0].append(1)`, what is `rows`?

  1. `[[0, 1], [0], [0]]`
  2. `[[0], [0], [0]]`
  3. `[[0, 1], [0, 1], [0, 1]]`Ճիշտ պատասխան
  4. `[[0], [1], [0]]`

Բացատրություն

List repetition duplicates references to the one inner list, so the append changes the object seen at all three positions. The compact syntax does not construct three independent nested lists or perform a deep copy.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 36: After `rows = [[0]] * 3` and `rows[0].append(1)`, what is… · Python Fundamentals · Questena