how to sort list in descending order in python
#1 Changes list
list.sort(reverse=True)
#2 Returns sorted list
sorted(list, reverse=True)
how to sort list in descending order in python
#1 Changes list
list.sort(reverse=True)
#2 Returns sorted list
sorted(list, reverse=True)
order a list without sort
n = int(input("Elementos da lista = "))
lista = []
for i in range(n):
x = int(input("Valor (0 a 9) = "))
if (i == 0) or (x > lista[- 1]):
lista.append(x)
else:
pos = 0
while (pos < len(lista)):
if x <= lista[pos]:
lista.insert(pos , x)
break
pos = pos + 1
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us