Hackerrank - CamelCase Solution
1 min read

Hackerrank - CamelCase Solution

Hackerrank - CamelCase Solution

Alice wrote a sequence of words in CamelCase as a string of letters, , having the following properties:

  • It is a concatenation of one or more words consisting of English letters.
  • All letters in the first word are lowercase.
  • For each of the subsequent words, the first letter is uppercase and rest of the letters are lowercase.

Given , print the number of words in  on a new line.

For example, . There are  words in the string.

Function Description

Complete the camelcase function in the editor below. It must return the integer number of words in the input string.

camelcase has the following parameter(s):

  • s: the string to analyze

Input Format

A single line containing string .


Output Format

Print the number of words in string .

Sample Input


Sample Output



String  contains five words:

  1. save
  2. Changes
  3. In
  4. The
  5. Editor

Thus, we print  on a new line.

Need help? Try this problem first to get familiar with HackerRank environment.

Solution in Python

print(len([1 for i in input() if i.isupper()])+1)

Enjoying these posts? Subscribe for more

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

That's okay. But without advertising-income, we can't keep making this site awesome.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add thepoorcoder.com to your ad blocking whitelist or disable your adblocking software.