Python,
pasted
on Apr 14:
|
def update_mapping(mapping_dict,check_word,solution_word):
for i,ele in enumerate(check_word):
if mapping_dict.has_key(ele):
if mapping_dict[ele] == "*":
mapping_dict[ele] = solution_word[i]
print mapping_dict,check_word,solution_word
m = {'a':'x', 's':'*'}
c = ['a', 's']
s = ['all right', 'so much']
print '+++++++++'
print m,c,s
print '######'
update_mapping(m, c, s)
print '------------'
print m, c, s
|
Output:
|
+++++++++
{'a': 'x', 's': '*'} ['a', 's'] ['all right', 'so much']
######
{'a': 'x', 's': 'so much'} ['a', 's'] ['all right', 'so much']
------------
{'a': 'x', 's': 'so much'} ['a', 's'] ['all right', 'so much']
|
|