defdiamond(n):# Make some diamonds!
ifn%2==0orn<=0:returnNoneifn==1:return"*\n"array=list(range(1,n+1))result=""white_space_count=list(range(1,int((n-(n%2))/2)+1))white_space_count.reverse()white_space_index=0forcountinarray:ifcount%2==0:continueifwhite_space_index!=len(white_space_count):result+=(" "*white_space_count[white_space_index])white_space_index+=1result+=("*"*count)+"\n"array.reverse()array=array[1:]white_space_count.reverse()white_space_index=0forcountinarray:ifcount%2==0:continueifwhite_space_index!=len(white_space_count):result+=(" "*white_space_count[white_space_index])white_space_index+=1result+=("*"*count)+"\n"returnresult
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is my simple diamond solution with Python: