[Solved] Python 3.5: Function not yielding the proper results [closed]


The problem with your code is simple. When count equals 3, you want to add a newline after printing out the last digit, otherwise the next set of 4 numbers will be printed on the same line. So, in summary, this is what you do:

if count == 3:
    print(i)
    count = 0

One handy trick to solving this problem another way is to chunk your input into small lists and print each one separately.

for i in range(0, len(numbers), 4):
     print(*numbers[i:i + 4])

91 77 14 36
1 88 13 88
19 40 90

Use python’s list slicing notation to get slices of 4 numbers at a time [i : i + 4] and then call print with the * argument to unpack them.

1

solved Python 3.5: Function not yielding the proper results [closed]