[ create a new paste ] login | about

Link: http://codepad.org/ACxleA2L    [ raw code | output | fork ]

Python, pasted on Apr 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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:
1
2
3
4
5
6
+++++++++
{'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']


Create a new paste based on this one


Comments: