Skip to content
Advertisement

draw a box that takes a input as the box size

I’m trying to learn Python. One of the tasks is to make a box with a dynamic box.

Here’s an example of how it’s supposed to work:

JavaScript

Here’s my code:

JavaScript

My box is all wrong:

enter image description here

Advertisement

Answer

You just need to centre align your string to the correct width, replace the middle print statement with:

print(symbol, string.center(int(integer)), symbol)

Edit:

Also, in case you aren’t aware, you can put the print statements within the input():

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement