Get formatting working
This commit is contained in:
parent
9266b01e42
commit
65d68f6101
1 changed files with 20 additions and 0 deletions
20
thinkcspy/Chapter-16-Exercises/pascal.py
Normal file
20
thinkcspy/Chapter-16-Exercises/pascal.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
def pascal(row):
|
||||||
|
num = 0
|
||||||
|
|
||||||
|
if row < 0:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if row <= 2:
|
||||||
|
num = 1
|
||||||
|
#elif row > 2 print
|
||||||
|
|
||||||
|
for i in range(row+1):
|
||||||
|
if i == 0:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
print((" "*(row-i)) + (f"{num} "*i) + (" "*(row-i)))
|
||||||
|
|
||||||
|
|
||||||
|
pascal(8)
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in a new issue