In [19]: for rps in zip(*(thing.split('\n') for thing in (rock, paper, scissors))):
...: print(("%-25s"*3)%(rps))
...:
Rock Paper Scissors
_______ _______ _______
---' ____) ---' ____)____ ---' ____)____
(_____) ______) ______)
(_____) _______) __________)
(____) _______) (____)
---.__(___) ---.__________) ---.__(___)
In [20]:
More flexibility?
In [24]: def pol(*list_of_things):
...: return '\n'.join(("%-25s"*len(list_of_things))%(rps) for rps in zip(*(thing.split('\n') for thing in list_of_things)))
In [25]: print(pol(scissors, scissors, rock))
Scissors Scissors Rock
_______ _______ _______
---' ____)____ ---' ____)____ ---' ____)
______) ______) (_____)
__________) __________) (_____)
(____) (____) (____)
---.__(___) ---.__(___) ---.__(___)
In [26]:
Commentary
rock
, etc are single strings containing a few newline characters, and we want to print, on the same line, a line from rock
, a line from paper
and one from scissors
, so the first thing that we need to do is to split each string to obtain a list of list of strings
list_of_lists_of_strings = [thing.split('\n') for thing in (rock, paper, scissors)]
# [['rock', ' _______', ...], ['paper', ' _______', ...], [...]]
but we really need
[['rock', 'paper', 'scissors'],
[' _______', ' _______', ' _______'],
[..., ..., ...]
...,
]
that is, the transpose of the list of lists of strings, but this is a well known idiom in Python (it's not really a list, but…)
transposed_list = zip(*list_of_lists_of_strings)
at this point we can print each triple of elements in the transposed_list
using an appropriate format (%-25s
outputs a string 25 characters long, blank filled on the right).
Making this a function is left as an exercise…
Sub—commentary
IMO, as far as possible a function shouldn't provide side effects, like printing.