+ 2
The Spy Life code coach [Different Approach] [python]
code = input()[::-1] encode = "" for x in code: if x.isalpha() == True or x.isspace() == True: encode += x print(encode) PS: Suggestions are welcome 🙂
3 Respuestas
+ 10
Aquarius ,
the code is well done. not an important change, but just for information:
#if x.isalpha() == True or x.isspace() == True: # <<< instead of using this
if x.isalpha() or x.isspace(): # <<< we can also use this
+ 3
Some other possible approaches to remove characters from a string:
- use a list comprehension with a condition
- use the filter() function
0
Lothar , thanks this will make the code more organised..