pyton 程序内容的颠倒,运用 [](列表)
def reverse_string(s): """Returns the reversal of the given string.""" result = "" for char in s: result = char + result return result print reverse_string("hello")
输出的效果是: “olleh”
pyton 实现斐波那契数列
import math a = [0, 1] for i in range(1,41): a.append(a[-1] + a[-2]) print a