I want to be able to rewrite the code in as few lines as possible, possibly in list comprehension syntax. Here is what the output should be:
1|2|3
4|5|6
7|8|9
This is what I have thought up. The separator doesn't actually print the "|". Any suggestions?
for i in [1,2,3,4,5,6,7,8,9]:
print(i, sep = "|", end = "")
if (i) % 3 == 0:
print()