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.'
You might also like to view...
Compare the worker pool multi-threading architecture with the thread-per-request architecture.
What will be an ideal response?
A digital forensics analyst inspects electronic data to recover documents and files from data storage devices that may have been damaged or deleted.
Answer the following statement true (T) or false (F)
Identify the syntax of thecall()method.
A. function.call(arg1, arg2, arg3, ...) B. function.call(thisObj, arg1, arg2, arg3, ...) C. call.function(thisObj, arg1, arg2, arg3, ...) D. function.call(Obj1, Obj2,...)
There are ____ ways to build a heap.
A. one B. two C. three D. four