On Thu, 01 Oct 2015 01:48:03 -0700, gal kauffman wrote: > items = s.replace(' (', '(').replace(', ',',').split() > > items_dict = dict() > for item in items: > if '(' not in item: > item += '(0,0)' > if ',' not in item: > item = item.replace(')', ',0)') > > name, raw_data = item.split('(') data_tuple = tuple((int(v) for v in > raw_data.replace(')','').split(','))) > > items_dict[name] = data_tuple
Please don't top post. What happens if there's more whitespace than you allow for preceding a '(' or following a ',', or if there's whitespace following '('? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list