据我所知,你要求用户输入行的形状和数量。
当这个程序提示用户输入行时,他应该为给定的任何形状键入10,但是如果您不希望用户选择行数,只需注释掉#j=int(input(“Enter rows:”)并将其替换为全局变量j=10。在s=str(input("Enter your shape(s for square, t for triangle or r for rectangle): "))
j=int(input("Enter rows: "))
shape=str(s)
if shape == 't':
print(" I'm a pyramid")
print()
for x in range(0,j):
for z in range(0,j-x-1):
print(end=" ")
for z in range(0,2*x+1):
print('#',end="")
print()
print()
print(" I'm a pyramid")
print('____________________')
print()
elif shape == 's':
print(" I'm a square")
print()
for x in range (1,10):
for z in range(20,1,-1):
print("#", end='')
print(' ')
print()
print(" I'm a square")
print('____________________')
print()
elif shape =='r':
print(" I'm a rectangle")
print()
for x in range (1,10):
for z in range(40,1,-1):
print("#", end='')
print(' ')
print()
print(" I'm a rectangle")
print('____________________')
print()
else:
print('Only the options given mate')