Write a Python Program to find sequences of one upper case letter followed by lower case letters. If found, print ‘Yes’, otherwise ‘No’.
Examples:
Input : Geeks Output : Yes Input : geeksforgeeks Output : No
Python regex to find sequences of one upper case letter followed by lower case letters
Using re.search() To check if the sequence of one upper case letter followed by lower case letters we use regular expression ‘[A-Z]+[a-z]+$’.
Python3
import re
from collections import Counter
def most_occr_element(word):
arr = re.findall(r'[0-9]+', word)
maxm = 0
max_elem = 0
c = Counter(arr)
for x in list(c.keys()):
if c[x]>= maxm:
maxm = c[x]
max_elem = int(x)
return max_elem
if __name__ == "__main__":
word = 'geek55of55gee4ksabc3dr2x'
print(most_occr_element(word))
Output:
Yes Yes No
Time complexity: O(n), where n is length of string. Auxiliary Space: O(1)
Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills and become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.
Last Updated :
31 Jul, 2023
Like Article
Save Article
Share your thoughts in the comments
Add Your Comment
Please Login to comment...