How do you count the words with a capital letter?



  • We have to figure out how many words begin with a capital letter in the line.



  • For example:

    words = 'Когда же Вы уроки будете делать САМИ?!!!'.split()
    

    res = len([word for word in words if word[0].isupper()])

    print(res)

    or so:

    res = sum(word[0].isupper() for word in words)


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2