You are viewing a single comment's thread. Return to all comments →
What I implemented in this problem: list methods, string split, data type conversion
Here's my code:
if name == 'main': N = int(input())
list_demo = [] for i in range(N): ip = input() s = ip.split() if s[0]=='insert': index = int(s[1]) list_demo.insert(index,int(s[2])) elif s[0]=='remove': list_demo.remove(int(s[1])) elif s[0]=='append': list_demo.append(int(s[1])) elif s[0]=='sort': list_demo.sort() elif s[0]=='pop': list_demo.pop() elif s[0]=='reverse': list_demo.reverse() else: print(list_demo)
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 →
What I implemented in this problem: list methods, string split, data type conversion
Here's my code:
if name == 'main': N = int(input())