Latest web development tutorials

Python includes exercises 70

Python 100 Li Python 100 Li

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.

Python 100 Li Python 100 Li