It seems that my decoration sometimes appears just outside the triangle... How can I fix this?
import random
n = int(input('enter n: '))
x = 1
for i in range(n):
if i == 0:
count = 0
else:
count = random.randint(0, x)
print(' ' * (n - i), '*' * count, end = '')
if i == 0:
print('&', end = '')
else:
print('o', end = '')
print('*' * (x - count - 1))
x += 2
What do I get for value n
= 10:
&
***o
*o***
o******
******o**
*********o*
*************o
*****o*********
*************o***
******************o
source https://stackoverflow.com/questions/70883922/my-decoration-sometimes-appears-just-outside-the-triangle
Comments
Post a Comment