If you could edit the following code to help it do the


If you could edit the following code to help it do the following "printDiamond" function; it only composes half of it currently, using python 3

printDiamond

For these "diamond" functions, you may use string multiplication, but only for strings of blank spaces, such as ' '*n or the like. Each visible character should be printed separately, just as in the functions earlier in this problem. Also, you don't have to use the string *operator for strings of spaces, either.

Compose a function called printDiamond( width, symbol ) that prints a diamond of symbol whose maximum width is determined by width.

printDiamond( 3, '&' )

   &

  & &

 & & &

  & &

   &

My code:

def printDiamond(width,symbol):

  for i in range(width):

    spaces = ""

    redundancy = symbol+""

    print(spaces*(width-i)+redundancy*i)

  for i in range(width):

    spaces = ""

    redundancy = symbol + ""

    print(spaces*i+redundancy*(width-i))

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: If you could edit the following code to help it do the
Reference No:- TGS02788782

Now Priced at $10 (50% Discount)

Recommended (90%)

Rated (4.3/5)