I have written a code in Python that includes a loop that provides 100 answers pertaining to one variable. So for example the output looks like this when I run it in the shell: (top to bottom)
1
2
3
4
5
etc...
How do I format this to show 10 outputs per line: (left to right)
1 2 3 4 5
Here is my code:
def main():
n = 0
while n <= 100:
if getPentagonalNumber(n):
n += 1
number = (n * (3*n - 1)) / 2
print (format(number, "5.0f"), end = ' ')
def getPentagonalNumber(n):
for n in range (1, 100):
if n > 100:
return False
return True
main()