任何人都可以在这里帮助我,我被困在将这段代码转换为递归函数的基本案例中......显然不能在递归函数中使用循环。
def diamond(a):
assert a > 0, "width must be greater than zero"
for i in range(0, a, 2):
for c in range(0, a - i, 2):
print(" ", end='')
if a % 2 == 0:
i += 1
for m in range(0, i - 1):
print("*", end='')
print()
for i in range (0, a, 2):
for c in range(0, i, 2):
print(" ", end='')
for m in range(0, a - i):
print("*", end='')
print()