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

After items = [1, 2, 3] and text = items[::-1], which description is correct?

  1. Both names refer to [3, 2, 1].
  2. text is empty unless explicit bounds are supplied.
  3. text is [3, 2, 1], while items stays [1, 2, 3].Ճիշտ պատասխան
  4. items changes to [3, 2, 1], while text is None.

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

The negative step visits the elements in reverse order and slicing constructs a result rather than rearranging the source list. Therefore text has reversed contents while items retains its original order.

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

Սկսել վարժանքը
Հարց 103: After items = [1, 2, 3] and text = items[::-1], which… · Python Fundamentals · Questena