You are viewing a single comment's thread. Return to all comments →
A shorter solution using the eval function:
if __name__ == '__main__': l = [] N = int(input()) for i in range(N): data = input().split() match (data[0], len(data)): case ('print', 1): print(l) case _: eval('l.'+data[0]+'('+','.join(data[1:])+')')
Seems like cookies are disabled on this browser, please enable them to open this website
Lists
You are viewing a single comment's thread. Return to all comments →
A shorter solution using the eval function: