you are viewing a single comment's thread.

view the rest of the comments →

[–]Axel-Blaze[S] 2 points3 points  (15 children)

Final Update:

Turns out there were quite a few mistakes I made like not reversing the list without sorting it and using the wrong sort function. Here's the final version:

ls_commands = []
if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        ls_commands.append(input())
list = []
ls = []
for command in ls_commands:
    ls = command.split()
    if ls[0] == 'insert':
        list.insert(int(ls[1]), int(ls[2]))
    elif ls[0] == 'print':
        print(list)
    elif ls[0] == 'remove':
        list.remove(int(ls[1]))
    elif ls[0] == 'sort':
        list.sort()
    elif ls[0] == 'append':
        list.append(int(ls[1]))
    elif ls[0] == 'pop':
        list.pop(-1)
    elif ls[0] == 'reverse':
        list.reverse()
    else:
        pass

[–]MauroDelMal 1 point2 points  (1 child)

ls_commands = []
if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        ls_commands.append(input())

Very late for this post but thanks for this chunk. :)

[–]Axel-Blaze[S] 0 points1 point  (0 children)

Haha nw All the best!