You are viewing a single comment's thread. Return to all comments →
I also used eval but yours is so much cleaner! Thanks!
L = [] for _ in range(0, int(raw_input())): user_input = raw_input().split(' ') command = user_input.pop(0) if len(user_input) > 0: if 'insert' == command: eval("L.{0}({1}, {2})".format(command, user_input[0], user_input[1])) else: eval("L.{0}({1})".format(command, user_input[0])) elif command == 'print': print L else: eval("L.{0}()".format(command))
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 →
I also used eval but yours is so much cleaner! Thanks!