Decode the Message LeetCode solution in Python

1
class Solution:
2
def decodeMessage(self, key: str, message: str) -> str:
3
mapping = {" ": " "}
4
i = 0
5
res = ""
6
letters = "abcdefghijklmnopqrstuvwxyz"
7

8
for char in key:
9
if char not in mapping:
10
mapping[char] = letters[i]
11
i += 1
12

13
for char in message:
14
res += mapping[char]
15

16
return res

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0