Skip to content

Instantly share code, notes, and snippets.

@ricardovsilva
Created February 2, 2016 13:59
Show Gist options
  • Save ricardovsilva/0ff09bc91b920957177e to your computer and use it in GitHub Desktop.
Save ricardovsilva/0ff09bc91b920957177e to your computer and use it in GitHub Desktop.
My solution for python-list exercise of hackerrank.com
quantity_commands = int(raw_input())
lines = []
for i in range(0, quantity_commands):
input = raw_input()
lines.append(input)
L = []
for line in lines:
parameters = str.split(line)
command = parameters[0]
if command == 'insert':
execution = 'L.' + command + '(' + parameters[1] + ',' + parameters[2] + ')'
exec execution
elif command == 'remove' or command == 'append':
execution = 'L.' + command + '(' + parameters[1] + ')'
exec execution
elif command == 'print':
execution = command + ' L'
exec execution
else:
execution = 'L.' + command + '()'
exec execution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment