循环语句--for&&while
for循环
Python for循环可以遍历任何序列的项目,如一个列表或者一个字符串。语法如下:
for iterating_var in sequence: statements(s)
>>>def digui(m): >>> count = 1 >>> for i in range(1, m+1): >>> count *= i >>> return count >>>print(digui(4)) 24
2023-10-25 21:08:28
循环语句--for&&while
for循环
Python for循环可以遍历任何序列的项目,如一个列表或者一个字符串。语法如下:
for iterating_var in sequence: statements(s)
>>>def digui(m): >>> count = 1 >>> for i in range(1, m+1): >>> count *= i >>> return count >>>print(digui(4)) 24