我很困惑似乎是一个简单的问题。一切都被正确计算和显示。我希望它水平打印并居中。此外,删除括号和逗号的方法将是加号。
from math import factorial
numcheck = False
while numcheck == False:
try:
height = (raw_input("Input height of Pascal's Triangle (must be integer): "))
height = int(height)
numcheck = True
except ValueError:
print "Not an integer!"
pascaltri = [[factorial(n) // (factorial(k) * factorial(n - k)) for k in range(n+1)]
for n in range(height)]
print pascaltri