First make from your string a list.
list_name = string_name.split(' ')
Then switch the keys and the values from your dict (if using python 3.x use iter instead of iteritems)
my_dict = {y:x for x,y in my_dict.iteritems()}
Then you can iter tro your code
for numbers in list_name:
print(my_dict[int(numbers)])
6
solved Python – Swap a value for a dictionary item