Skip to content

Instantly share code, notes, and snippets.

@ooade
Created November 21, 2019 08:19
Show Gist options
  • Save ooade/38d7d45444337d5805609f8fcbfbe8a6 to your computer and use it in GitHub Desktop.
Save ooade/38d7d45444337d5805609f8fcbfbe8a6 to your computer and use it in GitHub Desktop.
Python lists Hackerrank
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