I am a newbie to Python and trying to use print and for loop to print a pattern like following, where the width of block depends on the characters I want to enter, i.e. width of block and surrounding lines increase dynamically with length of string say, ABCDEFGHI.. :
┏━━━━━━━━━━┓
┃ ABCDE ┃
┗━━━━━━━━━━┛
I am trying to iterate over the characters of string like -
name = "abcdefghi"
for i in name:
print("━",end="")
print()
for j in range(1):
print("┃"+" "*(len(name)-1)+"┃")
for k in name:
print("━",end="")
which gives me an output like,
━━━━━━━━━━━━
┃ ┃
━━━━━━━━━━━━
- How can I use multiple loops to END the lines? (such that the pattern does not look like an open-ended box)
- Is there someway I can start the second loop index -1 than the line
━━━
pattern?
Need suggestions on what to try?