How to combine several of the automatically created lists into one new one?

Good afternoon.

Help to solve the problem:
b = dict(A='1' And='2', C='3')

After entering the input
a = input() (for example, "AIS")

We search for the keys in the dictionary and display each value
for i in a:
 if i is in b.keys():
 print(b[i], end=' ')
(example "1 2 3")

Question: since each value in the dictionary is a separate line, as it is possible to combine all rows into one new row?
Or, if the conversion of b[i] into the list as it is possible to combine each list into a new list?

After the unification into a single string or a list, you must add up all the values (1 2 3) with each other. At the end you should get a figure 1 +2 +3 = 6.
Thank you for your answer.
August 23rd 19 at 10:42
3 answers
August 23rd 19 at 10:44
Solution
Good afternoon.

>>> d = dict(x='5' y='10', z='15')

#letters = input()
>>> letters = 'xyz'
>>> d_values_sum = sum(int(d[i]) for i in letters if i in d)
>>> d_values_sum
30

>>> letters = 'xurfd'
>>> d_values_sum = sum(int(d[i]) for i in letters if i in d)
>>> d_values_sum
5
August 23rd 19 at 10:46
I do not quite understand what you need, just gonna leave this here:
Starting from 2 pips
this is a continuation
August 23rd 19 at 10:48
Something like this?
".join([b.get(i, ") for i in a])

Find more questions by tags Python