hey, I'm new here but heard a lot about some new stuff I could learn on here. However I'm kinda stuck on a program thats supposed to print a diamond depend what the user inputs as a width. Yes, I have seen this problem worked out in C++ before and I have spent a few hours trying to convert it into Python however I just can't seem to get the 'for' loop right. Any help on this part would be greatly appreciated.
printing diamonds
Collapse
X
-
Tags: None
-
-
Do you need something like this?? this is more a hint than a complete solution
-KudosCode:# print a diamond shape # c = 5; txt="" k = 0 for j in range(12): txt="" for i in range(12): if (i<c-k) or (i>c+k): txt+=" " else: txt+="*" print txt if(j>c): k-=1 elif(k<c): k+=1 else: k=c
Originally posted by dragonwebzhey, I'm new here but heard a lot about some new stuff I could learn on here. However I'm kinda stuck on a program thats supposed to print a diamond depend what the user inputs as a width. Yes, I have seen this problem worked out in C++ before and I have spent a few hours trying to convert it into Python however I just can't seem to get the 'for' loop right. Any help on this part would be greatly appreciated.Comment
Comment