Skip to content

Instantly share code, notes, and snippets.

@monk1337
Created December 25, 2017 14:07
Show Gist options
  • Save monk1337/19acd0b6f6605d2fe25d98e2160bb7c7 to your computer and use it in GitHub Desktop.
Save monk1337/19acd0b6f6605d2fe25d98e2160bb7c7 to your computer and use it in GitHub Desktop.
original = 'Has two optional arguments which must be specified.'
strings = [{'index': 3, 'string': 'foo'}, {'index': 7, 'string':
'bar'}, {'index': 12, 'string': 'abc'}]
meta_data=[(i['index'],i['string']) for i in strings]
track={}
for i,j in enumerate(original):
track[i]=j
for k in meta_data:
if k[0] in track:
if track[k[0]]==' ':
track[k[0]]=k[1]+' '
else:
track[k[0]] = k[1]
print("".join(track.values()))
#Hasfoo twobar optiabcnal arguments which must be specified.
original = 'Has two optional arguments which must be specified.'
strings = [{'index': 3, 'string': 'foo'}, {'index': 7, 'string':
'bar'}, {'index': 12, 'string': 'abc'}]
meta_data=[(i['index'],i['string']) for i in strings]
track={}
for i,j in enumerate(original):
track[i]=j
for k in meta_data:
if k[0] in track:
if track[k[0]]==' ':
track[k[0]]=k[1]+' '
else:
track[k[0]] = k[1]
print("".join(track.values()))
#Hasfoo twobar optiabcnal arguments which must be specified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment