def print_5xn(a):
A = int(len(a) / 5)
for i in range(A+1) :
print(a[i * 5: i * 5 + 5])
print_5xn("1234567898888")
12345
67898
888
def print_5xn(a):
A = int(len(a) / 5)
for i in range(A) :
print(a[i * 5: i * 5 + 5])
print_5xn("1234567898888")
12345
67898
I thought changing A+1 to A would result in the same result, but I want to know why the result is different.
range
See for yourself how the code works.
for i in range(3):
print(i)
for i in range(4):
print(i)
© 2024 OneMinuteCode. All rights reserved.