0

Why do I get 'None' after I execute this code:

list_1 = ['a', 'b', 'c']

list_2 = list_1.reverse()

print(list_2)

Thank you.

Frenk Frenk
  • 113
  • 7

1 Answers1

1

list_1.reverse() returns None, but instead it reverses list_1 itself.

In order to get a reversed result of list_1, you should do like this:

list_1 = ['a', 'b', 'c']

list_2 = list_1.copy()
list_2.reverse()

print(list_2)
Zephyr
  • 11,891
  • 53
  • 45
  • 80
Ahmed Mamdouh
  • 696
  • 5
  • 12