Latest web development tutorials

Python inclui exercícios 70

Python 100 Li Python 100 Li

Título: Escrever uma função, encontrar o comprimento de uma string, digite a string na função principal, e emite o seu comprimento.

Análise do Programa: Nenhum.

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)

O exemplo acima saída é:

please input a string:
abc
the string has 3 characters.

Python 100 Li Python 100 Li