def函数中python 3.6中的算术级数

时间:2022-12-08 19:05:21

I write python code in atom editor and make program arithmetic sequence in function

我在原子编辑器中编写python代码并在函数中生成程序算术序列

this is the code:

这是代码:

def arithmetic(n):
flag = n

for flag in range(10):
    number = []
    result =  number.append(flag**2)
    return result

the result when print(arithmetic(5)):

打印时的结果(算术(5)):

None

1 个解决方案

#1


1  

Check this code.

检查此代码。

def arithmetic(n):
    flag = n
    number = []
    for flag in range(10):
        number.append(flag**2)
    return number

print (arithmetic(4))

#1


1  

Check this code.

检查此代码。

def arithmetic(n):
    flag = n
    number = []
    for flag in range(10):
        number.append(flag**2)
    return number

print (arithmetic(4))