0

I need to get the pascal triangle after Iength of the triangle is inputted.I got it but it's not symmetrical .

x=raw_input("Input the height of the triangle : ") x=int(x) lst=[1,1] for i in range(x): print " "*(x-i-1), if i==0: print "1" continue for j in range(len(lst)): print lst[j]," ", print "" lst.insert(1,lst[0]+lst[1]) for j in range(i-1): lst[j+2]=lst[j+2]+lst[j+3]

1st Sep 2016, 3:47 PM
Nimsara
2 Réponses
+ 1
#---- try this ---- x=input("Input the height of the triangle : ") x=int(x) a = 1 lst=[1,1] for i in range(x): if i==0: print ("\n",end="") for s in range(x): print(" ",end="") print(" 1") continue for s in range(x-i): print(" ",end="") for j in range(len(lst)): print (" ",lst[j],end = " ") print ("\n") lst.insert(1,lst[0]+lst[1]) for j in range(i-1): lst[j+2]=lst[j+2]+lst[j+3]
1st Sep 2016, 5:40 PM
beauty1234
0
Message end= is syntactical error pops up when run
1st Sep 2016, 9:24 PM
Rupak Bhandari
Rupak Bhandari - avatar