Python Forum

Full Version: 'True' if 'string' has at least one uppercase letter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Do you have any suggestions on how to code: 'True' if 'string' has at least one uppercase letter, e.g. if 'maTh' then 'True'. I can't seem to find anything helpful considering string methods alone.

Thanks
>>> foo = 'maTh'
>>> any(ch.isupper() for ch in foo)
True
>>> foo = 'math'
>>> any(ch.isupper() for ch in foo)
False