- 1
How to find the number of words in pascalcase using python?
# Complete the 'calculateWordCount' function below. # # The function is expected to return an INTEGER. # The function accepts STRING S as parameter. # def calculateWordCount(S): # Your code here if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') s = input() noOfWords = calculateWordCount(s) fptr.write(str(noOfWords) + '\n') fptr.close()
2 Answers
+ 6
Ravikumar , sorry to say, but the code you presented here has no relationship to your question. (or may be your task description is incomplete)
âȘïžto get help from the community, please do a real try by yourself first, put the code in playground and link it here.
thanks for your understanding!
here some hints for you to do this task:
* as you mentioned, the function you should create expects to get a string, separated by a space or an other delimiter
* you have to iterate over this string, but you need to split it to individual words before
* during the iteration you have to check if the current word starts with a capital letter (pascal case is like "ShowName")
* you also need a variable to count the number of words in the string that starts with a capital letter
* at the end of the iteration your count variable holds a number that has to be returned to the calling part of the code
happy coding and good success!
+ 2
First please show your attempt on Playground and its link here.