How to check if capital letter found in a string with Python

2 Answers

0 votes
import re 
 
s = 'Python'
print(bool(re.search('([A-Z])', s)))

s = 'java'
print(bool(re.search('([A-Z])', s)))
    
    
    
'''
run:
    
True
False
    
'''

 



answered Jan 14, 2020 by avibootz
0 votes
s = 'Python'

print(any(ch in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for ch in s))

s = 'java'
print(any(ch in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for ch in s))
    
    
    
'''
run:
    
True
False
    
'''

 



answered Jan 14, 2020 by avibootz
...