Suppose I have a string of integers separated by commas of variable length. What is the best way to split the string and store the integers into variables?
Currently, I have the following.
input = sys.argv[1]
mylist = [int(x) for x in input.split(',')]
if len(mylist) == 2: a, b = mylist
else: a, b, c = mylist
Is there a more efficient way of doing this?
cif you (depending on the input) don't create it?