Lists in python - HackerRank solution
Solution for hackerRank problem Lists in python Problem Consider a list (list=[ ]). You can perform the following commands: Insert i e : integer at position. Print : Print the list. Remove e : Delete the first occurrence of integer. Append e : Insert integer at the end of the list. Sort : Sort the list. Pop : Remove the last element from the list. Reverse : Reverse the list. Initialize your list and read in the value of followed by lines of commands where each command will be of the types listed above. Iterate through each command in order and perform the corresponding operation on your list. Example N = 4 Append 1 Append 2 Insert 3 1 print Append 1 : Append to the list, .arr = [1] Append 2 : Append to the list, arr = [1, 2] Insert 3 1 : Insert 3 at index 1, arr = [1, 3, 2]. : Print the array. Output: [1, 3, 2] Input Format The first line contains an integer, n, denoting the number of commands. Each line i of the subsequent n lines contains one of the commands described abov