My problem is this.
1. Input N
2. Input N numbers are entered in the list. For example, N is 5 means 3,2,1,2,4 or 1,2,9,7,5 or 4,2,1,3,8 whatever, N is 3 means 1,2,3 or 7,4,8 or 2,13,26 whatever.
3. Input A and B
4. Sort descending order list only in index A to B. For example, N = 7 , input numbers are 3 2 0 6 7 9 1, A=2, B=5, the output is [3, 2, 9, 7, 6, 0, 1]
my output is like this
[3, 2, 6, 0, 7, 9, 1]
[3, 2, 7, 0, 6, 9, 1]
[3, 2, 9, 0, 6, 7, 1]
[3, 2, 9, 6, 0, 7, 1]
[3, 2, 9, 7, 0, 6, 1]
[3, 2, 9, 0, 7, 6, 1]
[3, 2, 9, 0, 6, 7, 1]
The problem is last 2 output is so weird, I don't know what am i doing wrong.
n = int(input())
list = []
for i in range(n):
list.append(int(input()))
a = int(input())
b = int(input())
b+=1
tmp=0
for i in range(a,b):
for j in range(a+1,b):
if list[i]<list[j]:
tmp=list[i]
list[i]=list[j]
list[j]=tmp
print(list)