Python: range operation with list -
i have list of elements this: [1/1/9-1/1/13, 1/1/20-1/1/22]
and print numbers in range between 9 , 13, 20 , 22
result= [1/1/10, 1/1/11, 1/1/12, 1/1/21 ] the range() method this, how catch them?
>>>test = ['1/1/9-1/1/13', '1/1/20-1/1/22'] >>>test = [tuple(x.split('-')) x in test] >>>print test [('1/1/9', '1/1/13'), ('1/1/20', '1/1/22')] >>>result = [x[:x.rfind('/')+1]+str(t) x,y in test t in range(int(x.split('/')[-1])+1, int(y.split('/')[-1]))] >>>print result ['1/1/10', '1/1/11', '1/1/12', '1/1/21'] i guess want.
Comments
Post a Comment