I have two dictionaries. One with full name:
a = { 'Иванов Иван Иванович': 12, 'Петров Петр Петрович': 34 } And another with initials:
b = { 'Иванов И. И.': 12, 'Петров П. П.': 34 } Full names in dictionaries and their meanings are absolutely identical. There is a line with the name:
c = 'Иванов Иван Иванович', 'Петров П. П.', 'Сидоров Сидр Сидрович' And there is a formula: ^ 3 ... here should be the number assigned for the full name ... ^ A ... here is the last name ... ^ B ... initials with dots, separated by spaces. This is how the formula looks like:
^312^AИванов^BИ. И. I need to get values from the dictionary and insert it into the formula for each full name. If Sodorov is not in the dictionaries, he will be without numbers. Expected Result:
^312^AИванов^BИ. И. ^334^AПетров^BП. П. ^AСидоров^BС. С. Only such inconvenient function came to my mind:
def get_code(): av = list(c) word = 'Иванов Иван Иванович' if word in av: return '^312^AИванов^BИ. И.' d = get_code() Can you please tell how to fully automate this process? Thanks in advance for your reply.