Counting characters
In a file called char_count.py
, write a function called ccount
.
That function returns the string that was passed to it as an argument, followed by a colon and the number of characters in the string, also called “string length”.
If your function is called with Yo, cats
for example,it will return Yo, cats:8
.
Use the test code below to validate your function.
The skeleton or your code is similar to the previous exercises.
Hint: you might need to use str()
to convert the string length to a string.
Test code
To validate your code, download the test code below and run it as explained on the Hello, Python exercise page.
Test code: char_count_test.py