Saturday, January 23, 2016

Print triangle shape using python


k = 5
for j in range(5 ,0, -1):
 if(j < k):
  print ((" " * (k - j)) + ("*" + " ") * (j))
 else:
  print  ("*" + " ") * (j)
#print "Done with descending"
for x in range(1, 6):

 if(x < k):
  print ((" " * (k - x - 1)) + ("*" + " ") * (x + 1))

No comments:

Post a Comment