l = [1,2,3,4,5,6,7,8,9,10]
I have a list and I need to print 5 elements per line to get:
1 2 3 4 5
6 7 8 9 10
I tried everything but I'm stuck, help!
l = [1,2,3,4,5,6,7,8,9,10]
I have a list and I need to print 5 elements per line to get:
1 2 3 4 5
6 7 8 9 10
I tried everything but I'm stuck, help!
 
    
    @Joaquin, try below code:
l = [1,2,3,4,5,6,7,8,9,10]
for index, item in enumerate(l):
    if (index + 1) % 5 == 0:
        print(item)
    else:
        print(item, end=" ")
"""
1 2 3 4 5
6 7 8 9 10
"""
