So what I am trying to do is make this "Triangle" in python with for loops:

But with the text like so:
0|0
1|01
2|012
3|0123
4|01234
What the output that I currently have is:
0|01234
1|01234
2|01234
3|01234
4|01234
And here is the code for the output:
def pascal(n):
answer = ""
for rows in range(n):
answer = str(rows) + "|"
for col in range(n):
answer = answer + str(col)
print(answer)
pascal(5)
My question is, how the heck do I make the ouput do this?(Im stumped as to what im supposed to do):
0|0
1|01
2|012
3|0123
4|01234
If anyone would like to see what the hell I was trying to accomplish, heres my solution
Soooooooo, this blue triangle:

turns into the pascal triangle, by "n choose k":

I was trying to figure out the for loops so I can have the basic setup done(which is the blue triangle), which you guys helped with :)
So the code that I came up with to get the n choose k is this:
def factorial(n):
answer = 1
for number in range(2, n+1):
answer = answer * number
return answer
def pascal(n):
answer = ""
for rows in range(n):
answer = ""
for col in range(rows+1):
answer = answer + str( int(factorial(rows) / (factorial(col)*factorial(rows-(col)))) )
print(answer)
pascal(10)
The factorial() is the exclamation point in the n choose k formula and I made the rest of the formula with this code:
factorial(rows) / (factorial(col)*factorial(rows-(col)))
So any n that is greater than 0, makes a pascal triangle :)
for col in range(n):. Shouldn't loop all the way tonrange(rows+1). But, the entire outer loop body can be replaced with:print(rows, "|", *range(rows+1), sep="")