Write a function that counts the characters in a string the user inputs. Then write a routine that calls the function and displays the following output.

$ ./count_letters.py
Enter some words: The rain in Spain
The string "The rain in Spain" has 17 characters in it.

$ cat count_letters.py
#!/usr/bin/python
def countEm(my_string):
count = 0
for s in my_string:
count += 1
return count
stg = raw_input('Enter some words: ')
print 'The string \"' + stg + '\"' + ' has ',
print countEm(stg),
print 'characters in it.'

Computer Science & Information Technology

You might also like to view...

________ is a popular picture format used by digital cameras because it can store a high-quality picture in a relatively small file

Fill in the blank(s) with correct word

Computer Science & Information Technology

The ________ event is used to intercept the saving of a record if any key fields are blank or if any fields contain data outside the acceptable boundaries

A) After Update B) On Load C) Before Update D) Before Insert

Computer Science & Information Technology