How to find the number of words in pascalcase using python? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
- 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()

17th Apr 2021, 5:49 AM
Ravikumar
Ravikumar - avatar
2 Respostas
+ 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!
17th Apr 2021, 7:13 AM
Lothar
Lothar - avatar
+ 2
First please show your attempt on Playground and its link here.
17th Apr 2021, 6:19 AM
JaScript
JaScript - avatar