import ast temp = "'mycode':['1','2','firstname','Lastname']" key,value = map(ast.literal_eval, temp.split(':')) status = {key: value}