def parse_range(astr):
result=set()
for part in astr.split(','):
x=part.split('-')
result.update(range(int(x[0]),int(x[-1])+1))
return sorted(result)
print(parse_range('1-10, 3, 4, 23-47'))
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]