Python includes exercises 70
Title: Write a function, find the length of a string, enter the string in the main function, and outputs its length.
Program Analysis: None.
Source Code:
#!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': s = raw_input('please input a string:\n') print 'the string has %d characters.' % len(s)
The above example output is:
please input a string: abc the string has 3 characters.