the idea of code enter height , form diamond asterisks (stars).
eg. if input height 6, i'd want code produce:
************ ***** ***** **** **** *** *** ** ** * * ** ** *** *** **** **** ***** ***** ************
i've gotten top half far , wondering if possible 'flip' lines horizontally.
height = int(input('enter triangle height: ')) star = height while star >= 1: = int(star)*'*' b = int(2*height-2*star)*' ' c = (height-star)*'' d = star*'*' print(a, b,c,d,sep='') star = star - 1 star = height while star >= 2: = int(star) b = int(2*height-2*star) c = int((height-star)) d = int(star) print(a*'*', b*' ',c*'',d*'*',sep='') star = star - 1`
change second while loop check if star <= height
, , increment star 2.
so like
star = 2 while star <= height: = int(star) b = int(2*height-2*star) c = int((height-star)) d = int(star) print(a*'*', b*' ',c*'',d*'*',sep='') star = star + 1
this because want go "small" "large" need inverse of first while loop decrements amount of *
's.
Comments
Post a Comment