equal
deleted
inserted
replaced
|
1 str_ranges = "1, 3-7, 12, 15, 18-21" |
|
2 |
|
3 ranges = str_ranges.split(',') |
|
4 |
|
5 lst = [] |
|
6 for r in ranges: |
|
7 vals = r.split('-') |
|
8 if len(vals) == 2: |
|
9 lst.extend(range(int(vals[0]), int(vals[1]) + 1)) |
|
10 else: |
|
11 lst.append(int(vals[0])) |
|
12 |
|
13 print lst |