I want to print the following pattern but the while loop for length is not running. When i run the code it only prints one triangle Below the code there is expected output and actual output :
height = int(input("Enter height ? "))
length = int(input("Enter length ? "))
spaces = height-1
spaces2 = 0
while length > 0:
for n in range(height):
for i in range(spaces):
print(' ',end="")
print('/',end="")
for j in range(spaces2):
print(' ',end="")
print('\\',end="")
for i in range(spaces):
print(' ', end="")
print('')
height-=1
spaces-=1
spaces2+=2
length-=1
Expected Output :
height = 5 length = 3
/\ /\ /\
/ \ / \ / \
/ \ / \ / \
/ \ / \ / \
/ \/ \/ \
Output when the code ran :
height = 5
length = 3
/\
/ \
/ \
/ \
/ \
Aucun commentaire:
Enregistrer un commentaire