Python - how to count number of uppercase letters in a string that is in a list -
For example, if I have this list:
s = ["Johnny and How can I calculate the number of uppercase letters in each element of this list of Python? "Annie", "great job people", "he and me"]
For this example, the Python 2, 1, 2 should be returned.
This is my code so far:
def poisci_pare (besedilo): x = [] seznam = [] T = re.split ("[.]", Besedilo) for e: x = x + e.split () in s: if s == s.capitalize () and s.startswith ('' '): Seznam.append (s)
This function creates a list where it separates sentences from dots and then filters all uppercase words into it, but I do not know how to calculate uppercase letters.
Try it out:
<
For this output Oga:
[sum] [2, 1, 2]
Comments
Post a Comment