Created
February 2, 2016 13:59
-
-
Save ricardovsilva/0ff09bc91b920957177e to your computer and use it in GitHub Desktop.
My solution for python-list exercise of hackerrank.com
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
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