Predict the output
What does this print?
s = "No lemon, no melon"
t = [c.lower() for c in s if c.isalnum()]
print(t == t[::-1], len(t))Choose an answer, then open Show answer below to check it.
Show answer
Answer: A True 14
Right: 14 letters remain and they read the same in both directions.
Filtering drops three spaces and a comma, leaving 'nolemonnomelon', which mirrors itself.
Why not the others?
- B False 18. 18 is the raw length with spaces and the comma; those are filtered out.
- C True 18. The filter drops 4 characters, so the length is 14.