Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert string ranges list python

def f(x):
    result = []
    for part in x.split(','):
        if '-' in part:
            a, b = part.split('-')
            a, b = int(a), int(b)
            result.extend(range(a, b + 1))
        else:
            a = int(part)
            result.append(a)
    return result
Comment

PREVIOUS NEXT
Code Example
Python :: sort decreasing python 
Python :: save standard output in variable python 
Python :: 151 - Power Crisis 
Python :: set lable of field django 
Python :: python how to write array into matlab file 
Python :: odoo docker addons path 
Python :: turtle screen 
Python :: get values from list of dictionaries python 
Python :: display column names as a dictionary pandas 
Python :: get legend lables and handles from plot in matplotlib 
Python :: how to define the range of values in seaborn heatmap 
Python :: iterate over rows in numpy matrix python 
Python :: gene wilder pure imagination 
Python :: pandas most and least occurrence value 
Python :: mid point circle drawing 
Python :: new print on the same line substitution python 3 
Python :: enumerate word python 
Python :: foreign key django createview 
Python :: Display shape of the DataFrame 
Python :: mistborn series 
Python :: python histogram one liners 
Python :: access cmd with python 
Python :: logging python 
Python :: call shell script from python 
Python :: Access Google Photo API with Python using google-api-python-client 
Python :: python get bits from byte 
Python :: python if file exist 
Python :: ipython play audio 
Python :: selenium webdriver without opening browser 
Python :: how can I convert dataframe to list with in python without changing its datatype? 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =