Created
November 21, 2019 08:19
-
-
Save ooade/38d7d45444337d5805609f8fcbfbe8a6 to your computer and use it in GitHub Desktop.
Python lists Hackerrank
This file contains hidden or 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()) | |
mylist = [] | |
for _ in range(N): | |
command, *numbers = input().split() | |
if command == 'print': | |
print(mylist) | |
elif len(numbers) == 0: | |
getattr(list, command)(mylist) | |
elif len(numbers) == 1: | |
getattr(list, command)(mylist, int(numbers[0])) | |
else: | |
a, b = numbers | |
getattr(list, command)(mylist, int(a), int(b)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment