Skip to content

Commit 0d7ed14

Browse files
authored
Refactoring the syntax using list comprehension
1 parent 71e8ed8 commit 0d7ed14

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

strings/detecting_english_programmatically.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ def get_english_count(message: str) -> float:
3333

3434

3535
def remove_non_letters(message: str) -> str:
36-
letters_only = []
37-
for symbol in message:
38-
if symbol in LETTERS_AND_SPACE:
39-
letters_only.append(symbol)
36+
letters_only = [symbol for symbol in message if symbol in LETTERS_AND_SPACE]
4037
return "".join(letters_only)
4138

4239

0 commit comments

Comments
 (0)