I am trying to solve a problem. While trying to change list values, I have observed a strange list behaviour. I can't change the values of the list elements.
top = list(map(int, raw_input().split()))
staff = list(map(int, raw_input().split()))
ceo  = top[0]
coo = top[1]
cto = top[2]
top.extend(staff)
alls = sorted(top)
tot = len(alls)
print(alls)
alls[tot/2], alls[alls.index(ceo)] = alls[alls.index(ceo)], alls[tot/2]
print(alls)
alls[0], alls[alls.index(coo)] = alls[alls.index(coo)], alls[0]
alls[-1], alls[alls.index(cto)] = alls[alls.index(cto)], alls[-1]
print(alls)
Here is the output of the program:
Input:
13 11 17
12 10
Output
[10, 11, 12, 13, 17]
[10, 11, 12, 13, 17]
[10, 11, 12, 13, 17]
Why are all list values not changing? Am I doing something wrong?
EDIT: Question statement: https://www.hackerearth.com/codejunk/algorithm/steal-the-show/
I know my approach is not the best way to solve this problem but I just want to know why values of list is not changing?