Get formatting to work with function
This commit is contained in:
parent
a7aa176139
commit
37aef85629
1 changed files with 16 additions and 10 deletions
|
|
@ -4,16 +4,22 @@ def pascal(row):
|
||||||
if row < 0:
|
if row < 0:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if row <= 2:
|
|
||||||
num = 1
|
|
||||||
#elif row > 2 print
|
|
||||||
|
|
||||||
for i in range(row+1):
|
for i in range(row+1):
|
||||||
if i == 0:
|
spaces = (" "*(row-i))
|
||||||
continue
|
nums = f"{getbinomial(num, i)} "
|
||||||
else:
|
print(spaces + nums + spaces)
|
||||||
print((" "*(row-i)) + (f" {num} "*i) + (" "*(row-i)))
|
|
||||||
|
|
||||||
|
# if row == 0 or 1: num = 1
|
||||||
|
# the first and last instance of i always == 1
|
||||||
|
#elif row % 2 == 0:
|
||||||
|
# increase until the middle number then decrease
|
||||||
|
#elif row % 2 == 1:
|
||||||
|
# increase until the halfway point, then decrease
|
||||||
|
|
||||||
|
|
||||||
|
def getbinomial(num, iters):
|
||||||
|
|
||||||
|
return f"{num+iters} " * iters
|
||||||
|
|
||||||
pascal(8)
|
pascal(8)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue