Printing dynamic ascii-art shapes based on user input In the following code I used a while True: loop and implemented break, because I couldn't figure out a cleaner solution than an infinite loop. Is this approach considered bad practice? Here is my code:
while True:
    z = int(input(&quot;Y: &quot;))

    if (z &gt;= 0 and z &lt;= 20):
        break

for x in range(z):

    print(&quot;-&quot; * (z-x) + &quot;*&quot; * x + &quot; &quot; * x + &quot;-&quot; * (z-x))

... which outputs:
Y: 12
------------------------
-----------* -----------
----------**  ----------
---------***   ---------
--------****    --------
-------*****     -------
------******      ------
-----*******       -----
----********        ----
---*********         ---
--**********          --
-***********           -
I couldn't figure out a cleaner solution than an infinite loop. Is this approach considered bad practice?

You can't do much better, since Python doesn't have the equivalent of a C-style do/while.
This is a trivial program so I doubt it's even worth adding functions (etc.); the one thing that can be improved is
if (z &gt;= 0 and z &lt;= 20):

can be
if 0 &lt;= z &lt;= 20: