In this example we will count the number of words in a given line
#!/usr/bin/env python
s = raw_input("Enter a line: ")
print "The number of words in the line are %d" % (len(s.split(" ")))The output
[kd@kdlappy book]$ ./countwords.py Enter a line: Sayamindu is a great programmer The number of words in the line are 5