Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python 3.6中def函数的算术级数_Python_Python 3.x_Data Structures - Fatal编程技术网

python 3.6中def函数的算术级数

python 3.6中def函数的算术级数,python,python-3.x,data-structures,Python,Python 3.x,Data Structures,我在atom编辑器中编写python代码,并在函数中生成程序算术序列 代码如下: def arithmetic(n): flag = n for flag in range(10): number = [] result = number.append(flag**2) return result 打印时的结果(算术(5)): 检查此代码 def arithmetic(n): flag = n number = [] for flag in

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

代码如下:

def arithmetic(n):
flag = n

for flag in range(10):
    number = []
    result =  number.append(flag**2)
    return result
打印时的结果(算术(5)):

检查此代码

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

print (arithmetic(4))

可能重复的
append/extend
始终返回
NoneType
代码未正确缩进。请编辑您的代码。在Python3.x中,这将引发一个错误。调用
print
Thank You@Eskapp时需要括号,我刚刚用2.7版本测试过你太有帮助了@skrGlad我可以帮助@MuhammadAkbar
def arithmetic(n):
    flag = n
    number = []
    for flag in range(10):
        number.append(flag**2)
    return number

print (arithmetic(4))