for elem in L:
    if '-' not in elem:
        answer.append(elem)
continue
start, end = elem.split('-')
answer.extend(map(str, list(range(int(start), int(end) + 1))))
Expanding a block of numbers in Python