import random
lst = list()
for i in range (0,10,1) :
lst.append(random.randint(0,100))
print(lst)
maxidx = 0
for i in range(0,10,1):
if lst[maxidx]<lst[i] :
maxidx=i
tmp =lst[maxidx]
lst[maxidx] = lst[9]
lst[9] = tmp
print(lst)
maxidx = 0
for i in range(0,9,1):
if lst[maxidx]<lst[i] :
maxidx=i
tmp =lst[maxidx]
lst[maxidx] = lst[8]
lst[8] = tmp
Find a large number and change the position with the element on the right by the way I'm going to repeat this to make it list from the left to the small number to the big number How do I make a repeat sentence?
for loops list
If you want the result, You can do lst.sort()
If you're going to practice, write a double for statement
for i in range(0,9,1):
maxidx = 0
for j in range(0,9-i,1):
Why don't you write a repeat in the same way?
© 2024 OneMinuteCode. All rights reserved.