Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.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循环不去Else语句_Python_Python 3.x - Fatal编程技术网

Python内部For循环不去Else语句

Python内部For循环不去Else语句,python,python-3.x,Python,Python 3.x,我只是想知道我的代码为什么不一直到第11行,我想循环自动计数,或者我需要以某种方式重置计数器吗?轻微调整,注意范围(0,1)函数只创建一个迭代器,其中一个值为0。所以它一直计算到(但不包括)1 列的for循环只有一个变量,它是零。这是你为范围(0,1,1)中的列循环:将这一行更改为范围(0,2)中的列循环:哇,这么简单的解决方法啊哈,从技术上讲,我认为0等于1,例如0=1=2等。要自己调试它,你可以打印列的值 #variable declarations array_value = str #d

我只是想知道我的代码为什么不一直到第11行,我想循环自动计数,或者我需要以某种方式重置计数器吗?

轻微调整,注意范围(0,1)函数只创建一个迭代器,其中一个值为0。所以它一直计算到(但不包括)1


列的
for循环
只有一个变量,它是零。这是你为范围(0,1,1)中的列循环
将这一行更改为范围(0,2)中的列循环
哇,这么简单的解决方法啊哈,从技术上讲,我认为0等于1,例如0=1=2等。要自己调试它,你可以打印列的值
#variable declarations
array_value = str
#declares the two dimensional array as a string
Zoo_Animal = [["", ""], ["",""], ["",""], ["",""], ["",""], ["",""]]
#loading the array
for row in range(0,6,1):
    for column in range(0,1,1):
        #determining the input statement
        if column == 0:
            array_value = input("Enter the name of a Zoo animal: ")
        else:
            array_value = input("Enter where the animal came from: ")
        #end if
          #adding the input value to the array
        Zoo_Animal[row][column] = array_value
    #end For
#end For
print(Zoo_Animal)
#variable declarations
array_value = str
#declares the two dimensional array as a string
Zoo_Animal = [["", ""], ["",""], ["",""], ["",""], ["",""], ["",""]]
#loading the array
for row in range(0,6,1):
    for column in range(0,2):
        #determining the input statement
        if column == 0:
            array_value = input("Enter the name of a Zoo animal: ")
        else:
            array_value = input("Enter where the animal came from: ")
        #end if
          #adding the input value to the array
        Zoo_Animal[row][column] = array_value
    #end For
#end For
print(Zoo_Animal)