You are viewing a single comment's thread. Return to all comments →
Slightly more concise take on this eval approach:
arg1 = input() l = [] for _ in range(int(arg1)): s = input().split() if (s[0] != 'print'): eval("l.{}(".format(s[0])+','.join(s[1:])+")") else: print(l)
Also worth noting that unpacking a list with *l or a dictionary with **dict could be useful in similar problems.
Seems like cookies are disabled on this browser, please enable them to open this website
Equal
You are viewing a single comment's thread. Return to all comments →
Slightly more concise take on this eval approach:
Also worth noting that unpacking a list with *l or a dictionary with **dict could be useful in similar problems.