Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.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 for循环冒号会出现语法错误?_Python_For Loop_Syntax Error - Fatal编程技术网

为什么python for循环冒号会出现语法错误?

为什么python for循环冒号会出现语法错误?,python,for-loop,syntax-error,Python,For Loop,Syntax Error,为什么python for循环冒号会出现语法错误 a=int(input("Enter a number.") for x in range(a): print(" ") c=int(input("Enter another number.") for x in range(c): print("x") 没有一个机器人是对的 另外,在第二个循环中,您甚至没有打印x变量的值,只是一个“x” 此问题只是输入行中缺少的括号: a=int(输入(“输入一个数字”)和c=int(输入(“

为什么python for循环冒号会出现语法错误

a=int(input("Enter a number.")
for x in range(a):
    print(" ")
c=int(input("Enter another number.")
for x in range(c):
    print("x")
没有一个机器人是对的

另外,在第二个循环中,您甚至没有打印x变量的值,只是一个“x”


此问题只是输入行中缺少的括号:
a=int(输入(“输入一个数字”)
c=int(输入(“输入另一个数字”)


您的代码中存在简单的输入错误,请参阅a、c声明,其中缺少了一个括号

a=int(input("Enter a number."))
for x in range(a):
    print(" ")
c=int(input("Enter another number."))
for x in range(c):
    print("x")

希望有帮助。

您没有关闭
int
函数调用…这与问题无关,但我建议使用
xrange
原始输入。
a=int(input("Enter a number."))
for x in range(a):
    print(" ")
c=int(input("Enter another number."))
for x in range(c):
    print("x")
a=int(input("Enter a number."))
for x in range(a):
    print(" ")
c=int(input("Enter another number."))
for x in range(c):
    print("x")