python - how do i get a value from a dictionnary format ('B','A'):value -


i generated dictionnary out of table , looks bit :

d= {'d', 'v'): -5, ('n', 'm'): -3, ('x', 'm'): -1, ('w', 's'): -4,      ('r', 'c'): -5, ('x', 'z'): -1, ('v', 'w'): -3, ('b', 'j'): -5,      ('r', 'n'): -1, ('m', 't'): -1, ('s', 'i'): -3, ('x', 'b'): -1,      ('r', 'l'): -3, ('s', 'c'): -2, ('h', 'm'): -3, ('i', 'x'): -1,      ('w', 'h'): -3, ('q', 'h'): 1, ('k', '*'): -6, ('e', 'i'): -4,      ('r', 'p'): -3, ('f', 's'): -3, ('c', 'm'): -2, ('x', 'v'): -1,      ('s', 's'): 5, ('v', 'i'): 3, ('s', 'x'): -1, ('e', 'm'): -3,      ('m', 'f'): -1, ('r', 's'): -1, ('y', 'n'): -3} 

two strings s1="sacv" , s2="xscs" want value ('s','x') how value doing d[[s1[s]][s2[x]]]

typeerror: list indices must integers, not str

and doing d[[s1[s]]+[s2[x]]]

typeerror: unhashable type: 'list'

first of need correct this:

d= {'d', 'v'): -5, (...) >> d= {('d', 'v'): -5, (...)

after doing need call as: return d[('s', 'x')] or print d[('s', 'x')]

this should work. otherwise let know


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -