“Lista odwrócona Python” Kod odpowiedzi

Odwrotna lista Python

>>> the_list = [1,2,3]
>>> reversed_list = the_list.reverse()
>>> list(reversed_list)
[3,2,1]

OR

>>> the_list = [1,2,3]
>>> the_list[::-1]
[3,2,1]
Thoughtful Trout

Jak odwrócić listę wstecz w Pythonie

myList = [0,1,2,3,4,5]
myList.reverse()
print(myList)
#OR
print(myList[::-1])
Coding Lemons

Jak odwrócić listę w Python

# Use the reversed function:
xs = [0, 10, 20, 40]
for i in reversed(xs):
  print(i)

# To get a reversed list:
list(reversed(xs))
[40, 20, 10, 0]
codeconnoisseur

Lista odwrotna Pythona

>>> xs = [0, 10, 20, 40]
>>> xs[::-1]
[40, 20, 10, 0]
Mysterious Mongoose

Odwrotna lista Python

list=[1,2,3]
list[::-1]
Godhacked

Lista odwrócona Python


# Making a new list
myList = [1,2,3,4]
# Inverting the list
myList = myList[::-1]
Anxious Aardvark

Odpowiedzi podobne do “Lista odwrócona Python”

Pytania podobne do “Lista odwrócona Python”

Więcej pokrewnych odpowiedzi na “Lista odwrócona Python” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu