avatar Bite 146. Rhombus generator

In this Bite you make a generator of rhombus shapes. You will complete gen_rhombus that when called like this:

  gen = gen_rhombus(5)  # gen_rhombus is a generator
  for row in gen:
      print(row)


... will generate the following output:

  *
 ***
*****
 ***
  *

When called with a greater width (you only have to worry about uneven widths for this exercise):

  gen = gen_rhombus(11)
  for row in gen:
      print(row)


... the output would be:

     *
    ***
   *****
  *******
 *********
***********
 *********
  *******
   *****
    ***
     *

So the middle row is always equal to the width passed in. Checkout how format or f-strings can help you here, as well as the range builtin. Have fun!

Login and get coding
go back Intermediate level
Bitecoin 3X

Will you be Pythonista #123 to crack this Bite?
Resolution time: ~47 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 1.86 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help