list fun
unknown
python
4 years ago
876 B
7
Indexable
N = int(input())
res = []
for i in range(N):
command = input()
if 'insert' in command:
insert_list = command.split()
list_index = int(insert_list[1])
list_element = int(insert_list[2])
exec('res.insert(list_index, list_element)')
if 'remove' in command:
remove_list = command.split()
list_element = int(remove_list[1])
exec('res.remove(list_element)')
if command == 'pop':
exec('res.pop()')
if 'append' in command:
append_list = command.split()
append_element = int(append_list[1])
exec('res.append(append_element)')
if command == 'sort':
exec('res.sort()')
if command == 'reverse':
exec('res = res[::-1]')
if command == 'print':
exec('print(res)')Editor is loading...