In my question a few minutes ago, I asked about how to print using python's str.format
printing, when the strings are stored in an array.
Then answer was clearly unpack the list, like this:
# note that I had to play with the whitespace because the {} text is 2 characters, while its replacement is always one
hex_string = r'''
_____
/ \
/ \
,----( {} )----.
/ \ / \
/ {} \_____/ {} \
\ / \ /
\ / \ /
)----( {} )----(
/ \ / \
/ \_____/ \
\ {} / \ {} /
\ / \ /
`----( {} )----'
\ /
\_____/
'''
letters = list('1234567')
print(hex_string.format(*letters))
But if I always want the center hexagon to have printed inside the first item in the array: letters[0]
, how can I mix unpacking the array with keeping the 4th printed string from the first array element?
I'm open to other printing types, like f-strings.
For example:
print(hex_string.format(letters[3], letters[1], letters[2], letters[0], letters[4], letters[5], letters[6]))
So that my output actually looks like this:
_____
/ \
/ \
,----( 4 )----.
/ \ / \
/ 2 \_____/ 3 \
\ / \ /
\ / \ /
)----( 1 )----(
/ \ / \
/ \_____/ \
\ 5 / \ 6 /
\ / \ /
`----( 7 )----'
\ /
\_____/