I would like to ask again the help of the Python experts in this forum. The task is to create a program that will return a triangle pattern. However, there must be a siblings.
Sample input:
Input an Integer:
9
Sample Output:
*
**
***
**** *
***** **
****** ***
******* **** *
******** ***** **
********* ****** ***
The code that I have so far is:
a = int(input("Input a number? "))
k=a/3
t=a-k
y=a-(k*2)
for i in range(a + 1):
print '*' * i
for i in range(t + 1):
print '*' * i
for i in range(y + 1):
print '*' * i
When I run this code the output is:
Input a number: 12
*
**
***
****
*****
******
*******
********
*********
**********
***********
************
*
**
***
****
*****
******
*******
********
*
**
***
****
It prints after the first triangle, my goal is to print it beside each triangle..
makes your triangles.
output:
or you could keep it all in the function and:
and if you want a space between them:
for fun (and you can see very nice function):
and more fun:
addition: some explanation of how it works:
this is what the code does in more basic form: