Lets manipulate some lists. Go on, it’ll be fun!
mystr = "1-2, 3, 5, 7-9, 12-20" finallist =  templist = mystr.split(",") # explode for z in range(len(templist)): # remove whitespace templist[z] = templist[z].strip() for x in range(len(templist)): if templist[x].isdigit(): finallist.append(int(templist[x])) else: span = str(templist[x]).split("-") for y in range(int(span), (int(span) + 1)): finallist.append(y) print(finallist)
This script takes a list written in a human readable (and, more to the point, easily human-writeable) format such as “1-2, 3, 5, 7-9, 12-20” and converts into a list (a kind of python array) for use by other functions.
I have implemented this into my JADOS program to good effect.