Hey guys how can I replace multiple numbers in a string for their values specified in a dict in one go? ex:
dic_lanches = {10:'Misto-Quente',11:'X-Burger',
               12:'X-Salada',
               13:'X-Egg',
               14:'X-Bacon',
               15:'X-Calabresa',
               16:'X-Frango',
               17:'X-Coração',
               18:'X-Casa'}
my_string = 11 12 13
after replace:
I want X-Burguer X-Salada X-Egg
But what I am getting is:
X-Burguer 12 13
11 X-Salada 13
11 12 X-Egg
now tried:
result = re.sub(r'\d', lambda x: dic_lanches[int(x.group())], myString)
but I'm getting KeyError 1
 
    