• + 1 comment

    Can any one help me why my code doesn't provide the correct answer in compiler, but when i run in jupyter notebook it gives me the answer.

    if name == 'main': N = int(input()) print('You need to perform {} commands'.format(N)) array = []

    for _ in range(N):
        func, *args = input("Enter the command and values : ").split()
        if func == "Insert":
            index, element = map(int, args)
            array.insert(index, element)
        elif func == "Print":
            print(array)
        elif func == 'Remove':
            element_remove = int(input('Enter the element to remove: '))
            array.remove(element_remove)
        elif func == "Append":
            element_append = int(input('Enter the element to append: '))
            array.append(element_append)
        elif func == "Sort":
            array.sort()
        elif func == "Print":
            print(array)
        elif func == 'Pop':
            array.pop()
        elif func == 'Reverse':
            array.reverse()
        elif func == "Print":
            print(array)
        else:
            print("Invalid Command")