Jan-11-2018, 04:26 PM
You can convert a string to a list using casting,
In the while loop, you increment
Given that you are just looping through words, why not use:
Why bother with checking if the character is in KEYPAD and then extracting it?
Just use
default_value can be left out (in which case,
words = list(word)
, no need to use the list comprehension.In the while loop, you increment
i
on both paths through the if statement, so why not have it just once below the if statement? Although, you don't really need a while loop.Given that you are just looping through words, why not use:
for ch in words:
which will give you each letter in turn (you know this already, from using list comprehension earlier).Why bother with checking if the character is in KEYPAD and then extracting it?
Just use
words.get(ch, default_value)
default_value can be left out (in which case,
None
is returned if there is no match).
I am trying to help you, really, even if it doesn't always seem that way