I have read a few of the Stack answers on similar issues to mine. I have only found one answer that results in the output I want and that was an answer by the user arshajii in the following question:
Print list in table format in python
His answer was:
>>> l1 = ['a', 'b', 'c']
>>> l2 = ['1', '2', '3']
>>> l3 = ['x', 'y', 'z']
>>> for row in zip(l1, l2, l3):
... print ' '.join(row)
a 1 x
b 2 y
c 3 z
The above is what I would like my format to be. I have tried his method but it doesn't work for my code. I have a feeling it's because the person that asked the question was talking about external files.... Can anyone help me rewrite this code into a non-external source format?
The optimal layout would result in the output being something like:
Letter a, Number 1, Letter x
Letter b, Number 2, Letter y
Letter c, Number 3, Letter z
With the letter and numbers actually being words printed (print "Letter ").
The below is the code I currently have:
for list in zip ([rounds], [numberOfHits], [score]):
print("Round " + str(rounds) + ": " + str(numberOfHits) + " shots. " + str(score)) .join(list)
But my output is:
Round [1, 1]: [6, 4] shots. 5 under par.
Rather than:
Round [1]: [6] shots. 3 under par.
Round [2]: [4] shots. 1 under par.
I keep getting the AttributeError: 'NoneType' object has no attribute 'join'. Anyone know why this is coming up?
Thank you in advance! Hopefully this is all understandable but if it isn't let me know.
(Please don't give me any solutions that require external programs. I am using PyCharm and would just like to stick to this type of coding before moving onto more advanced code.)