Python include esercizi 70
Titolo: Scrivere una funzione, trovare la lunghezza di una stringa, inserire la stringa nella funzione principale, ed emette la sua lunghezza.
Analisi del programma: Nessuno.
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)
L'output sopra esempio è:
please input a string: abc the string has 3 characters.