Latest web development tutorials

Python obejmuje ćwiczenia 27

Python 100 Li Python 100 Li

Tytuł: rekurencyjne wywołanie funkcji, pięć znaków wprowadzane są drukowane w kolejności odwrotnej.

Program Analysis: Brak.

Kod źródłowy:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

def output(s,l):
    if l==0:
       return
    print (s[l-1])
    output(s,l-1)
 
s = raw_input('Input a string:')
l = len(s)
output(s,l)

Powyższy przykład wyjście jest:

Input a string:abcde
e
d
c
b
a

Python 100 Li Python 100 Li