Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ranges_str = '1-2,8-15,23-25'
- ranges_list = ranges_str.split(',')
- result = []
- for record in ranges_list:
- start, end = map(int, record.split('-'))
- for num in range(start, end + 1):
- result.append(num)
- print(result)
- # [1, 2, 8, 9, 10, 11, 12, 13, 14, 15, 23, 24, 25]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement