class Solution:
def decodeMessage(self, key: str, message: str) -> str:
l=[]
for i in key:
if i==" ": #done to avoid having an element: " "
continue #the dict requires alphabet->alphabet
if i not in l:
l.append(i)
al="abcdefghijklmnopqrstuvwxyz"
d=dict(zip(l, list(al)))
res=""
for i in message:
if i==" ":
res+=" "
elif i in d:
res+=d[i]
return res
to avoid " " elements in l,
d={}
l=l.split()
l.join("")