0
How to make triangle of and(&) pattern in any programming language?
which language is better...
6 Antworten
+ 5
oops sorry
try this
w=20
char="&"
m_char=" "
print(char.center(w+1))
for i in range(1,w//2):
print((char + m_char*(2*i-1)+char).center(w+1))
print(char*(w+1))
+ 2
do you mean a triangular pattern made of &
if that is what you asked I think this will work (python3)
change values of w and char to change it
w=20
char="&"
for i in range(w//2):
print((char*(2*i+1)).center(w))
+ 2
like this?
w=20
char="&"
for i in range(w):
print(char*(i+1))
+ 2
thax for the logic
+ 1
i want & symbol only on the boundaries of triangle not the one you have given
+ 1
&
& &
& &
& &
&&&&&&&&&&
like this