Greetings,
I was playing around with a piece of code to remove lowercase letters
and leave behind uppercase letters from a string when I got unexpected
results.
string = 'Whiskey Tango Foxtrot'
list(filter((lambda x: not x.islower()), string))
['W', ' ', 'T', ' ', 'F']
Note the space characters in the list.
list(filter((lambda x: x.isupper()), string))
['W', 'T', 'F']
Note that there are no space characters in the list.
Shouldn't the results between 'not x.islower()' and 'x.isupper()' be
identical?
The final form of this code is this:
list(filter(str.isupper, string))
['W', 'T', 'F']
Thank you,
Chris R.
--
https://mail.python.org/mailman/listinfo/python-list