Python: How to convert a string with mixed numbers and ranges of numbers to a list

Conversion of a string with both individual numbers and ranges of numbers to the list of integer values can be made as follows:

For example a line:

Split the line by comma delimiter:

Let’s split the resulting list into two lists. In the first list, we put only the individual values. In the second – the values got from the ranges of numbers.

Combine the lists into one and drop the duplicate values.

Complete code: