changeset 64 | 333092b68926 |
63:f5eac04a00fe | 64:333092b68926 |
---|---|
1 str_range = '4-7, 9, 12, 15' |
|
2 |
|
3 ranges = str_range.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 set_range = set(lst) |
|
14 all_elems = set(range(min(lst), max(lst))) |
|
15 |
|
16 print all_elems - set_range |