我想在 for 循环找到“#”时拆分数组,我正在尝试在控制台中进行模拟,这就是用户将看到的。
但我在任何地方都找不到使这项工作有效的方法。
def grid(self):
while True:
size = input("Size of Map (N x N): ")
if size.isnumeric() and int(size) >= 2:
intSize = int(size) * int(size)
mapH = list()
map = list()
for elementos in range(1,intSize + 1):
if elementos%10 == 5 or elementos%10 == 0:
mapH.append(elementos)
mapH.append("#")
else:
mapH.append(elementos)
for el in mapH:
# I don't know what to make here
return map
else:
continue