Python 仅使用IF和else而不使用其他技术循环二维数组

Python 仅使用IF和else而不使用其他技术循环二维数组,python,Python,我希望尝试一个过去两年来一直困扰我的用例,现在希望解决我的这个问题 除了IF-Else之外,有没有一种方法可以在二维列表中循环而不使用任何for循环或其他方法 范例 我有一个2d列表-[3][6]//第一个和第二个可以随机更改,如果可能,我希望对其进行限制 x = 0 y = 0 Seriously I dont know how to start it so I dont have any method yet. But I will update it soon Since x and

我希望尝试一个过去两年来一直困扰我的用例,现在希望解决我的这个问题

除了IF-Else之外,有没有一种方法可以在二维列表中循环而不使用任何for循环或其他方法

范例

我有一个2d列表-[3][6]//第一个和第二个可以随机更改,如果可能,我希望对其进行限制

x = 0
y = 0

Seriously I dont know how to start it so I dont have any method yet. But I will update it soon

Since x and be increase by 1 everytime so I thought maybe below could be used. 

x += 1

it should loop through and show it this way

0-0
0-1
0-2
0-3 ....

1-0
1-1
1-2
1-3 .... and so on. 
更新:

试试这个


如果x如果递归可用,则此方法可能有效。 如果不能使用递归,则可能需要另一种方法来堆积If-else

#a[2][3]

def loop(x,y,x_max):
  if x>0:
    print loop(x-1,y,x_max)
  elif y>0:
    print loop(x_max,y-1,x_max)
  return y,x

print loop(len(a)-1,len(a[0])-1,len(a)-1)

输出:

0-0 0 - 1 0 - 2 0 - 3 1 - 0 1 - 1 1 - 2 1 - 3 2 - 0 2 - 1 2 - 2 2 - 3 3 - 0 3 - 1 3 - 2 3-3


我对您想在哪里/为什么使用它感兴趣。为什么不直接KISS呢?除非你能使用递归,否则没有for/while循环就无法在任意大小的数组上循环。1。你为什么要这么做?2.递归呢?
import itertools
print(str(list(itertools.product('0123','0123')))
                        .replace("', '"," - ")
                        .replace("('","")
                        .replace("')","")
                        .replace("[","")
                        .replace("]","")
                        .replace(", ","\n"))