I am trying to generate two sets of string images. 1st.
% % %
% % % % %
% %
%
2nd.
%
% %
% % %
% % % %
Note that the 2nd image is the same as the 1st image, just rotated counter-clockwise.
The number of lines and length of each line in the 1st image is based on a list, which can be of any length and consist of strictly positive numbers. In this example, our list is:
list = [3, 5, 2, 1]
I am having some trouble getting the 2nd image. For the first image, I have made use of the following function:
for e in list:
print(int(e) * '% '
Which seems to work. I am just not sure how to go about the 2nd image. I have some ideas around producing each row where I can find the highest element in list, find its index (in this example list[1]), and then incorporate " " on either side, depending on its distance to the beginning of the list and the end and going from there, but I am just not sure.
Any advice would be appreciated.
Thanks!
Aucun commentaire:
Enregistrer un commentaire