You are viewing a single comment's thread. Return to all comments →
Python Solution This solution uses switch statements.
if __name__ == '__main__': N = int(input()) l = [] for _ in range(N): command = input().split(' ') match command[0]: case 'insert': l.insert(int(command[1]), int(command[2])) case 'print': print(l) case 'remove': l.remove(int(command[1])) case 'append': l.append(int(command[1])) case 'sort': l.sort() case 'pop': l.pop() case 'reverse': l.reverse()
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Lists
You are viewing a single comment's thread. Return to all comments →
Python Solution
This solution uses switch statements.