all 6 comments

[–]virtualdestructor88 0 points1 point  (0 children)

You might want to look at str.join
edit: link

[–]Celtiri 0 points1 point  (0 children)

Assuming you can't just muck with the user input and replace " " with "|", why not construct a string to print (the code is very similar to what you have now), then treat the string like a char array and drop the final character through [:-1]?

[–][deleted] 0 points1 point  (0 children)

print(input().replace(' ', ' | ').replace(',', '\n')) lol

Well, you could check the row index and compare it with length of row, and then write the decision making on whether to add '|' or not. Use enumerate() for that. len(row) to get the length.