Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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.x_Python_Loops_Process - Fatal编程技术网

循环、列表、python 3.x

循环、列表、python 3.x,python,loops,process,Python,Loops,Process,尝试创建使用循环读取和处理的两列表。尝试创建显示整数及其平方根的列表。我已经用几种方法玩过这个程序,但是我不明白为什么会得到一个无效的语法 """with open('numbers.txt', 'w') as file: for i in range(5): #The loop number = 0 while (number < 10) or (number > 50): number = int(input("Enter integer {0}:

尝试创建使用循环读取和处理的两列表。尝试创建显示整数及其平方根的列表。我已经用几种方法玩过这个程序,但是我不明白为什么会得到一个无效的语法

"""with open('numbers.txt', 'w') as file:
for i in range(5): #The loop
    number = 0
    while (number < 10) or (number > 50):
        number = int(input("Enter integer {0}:  ".format(i+1)))
    number_str = "{0}\n".format(number)
    file.write(number_str)
file.close()"""

倒数第二行缺少一个右括号。应该是:

print (number, "\t\t\t%.4f" % round(square_root, 4))
print (number, "\t\t\t%.4f" % round(square_root, 4))