I'm working on an assignment where I have to code a program where the input and output are shown below:
Input: 1 2 3 4 5
Desired Output:
1| 2| 3| 4| 5
2| 4| 6| 8|10
3| 6| 9|12|15
I can't figure out how to properly do this but here is all my code so far:
row1 = [1*int(i) for i in input().split()]
row2 = [2*i for i in row1]
row3 = [3*i for i in row1]
row1= str(row1)
row1= '|'.join(row1)[2:-2]
row2 = str(row2)
row2= '|'.join(row2)[2:-2]
row3 = str(row3)
row3= '|'.join(row3)[2:-2]
my_list = [row1, row2, row3]
print(row1)
print(row2)
print(row3)
The output of my code is this which obviously isn't the desired output:
1|,| |2|,| |3|,| |4|,| |5
2|,| |4|,| |6|,| |8|,| |1|0
3|,| |6|,| |9|,| |1|2|,| |1|5
Please help me get the desired output which as shown above