Answer:
- def normalize(input_string):
- output = []
-
- for c in input_string:
- if(c.isalpha()):
- output.append(c.lower())
-
- return output
-
- print(normalize("O.K. #1 Python!"))
Explanation:
Firstly, create a function normalize that takes one input string (Line 1).
Next, we create an empty list and assign it to output variable (Line 2). This list will hold all the letters from the input string.
Create a for loop to traverse each of the character in the input string (Line 4) and then use isalpha() method to check if the current character is a letter (Line 5). If so, add the letter to output list (Line 6). Please note we can convert the letter to lowercase using lower() method.
After completing the loop, return the output list (Line 8).
We can test the function using the sample input given in the question (Line 10) and we shall get ['o', 'k', 'p', 'y', 't', 'h', 'o', 'n']