https://www.hackerrank.com/challenges/python-lists/problem
python에는 switch 가 없다,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
N = int(input()) | |
arr = [] | |
for i in range(N): | |
S = input() | |
cmd = S.split() | |
if(cmd[0] == 'insert'): | |
arr.insert(int(cmd[1]), int(cmd[2])) | |
elif cmd[0] == 'print': | |
print(arr) | |
elif cmd[0] == 'remove': | |
arr.remove(int(cmd[1])) | |
elif cmd[0] == 'append': | |
arr.append(int(cmd[1])) | |
elif cmd[0] == 'sort': | |
arr.sort() | |
elif cmd[0] == 'pop': | |
arr.pop() | |
elif cmd[0] == 'reverse': | |
arr.reverse() |
Posted by 빨강토끼