Can anyone explain to me why this isn't giving me the right output when the array value 0 is in the start position of the slicing operator. The following code gives me the right output:
array = [1, 0, 3, 1, 5, 6, 7, 8, 9, 0]
x = int(''.join(str(i) for i in array))
print("x = ",x)
a = int(str(x)[:3])
print("a = ",a)
b = int(str(x)[3:6])
print("b = ",b)
c = int(str(x)[6:10])
print("c = ",c)
output:
x = 1031567890
a = 103
b = 156
c = 7890
now if I change the first value of the array to a zero [0, 0, 3, 1, 5, 6, 7, 8, 9, 0]
it will skip the first 2 zeros but will still display the last zero of the array
output:
x = 31567890
a = 315
b = 678
c = 90
Same behaviour if I change the 4th position to a zero which is the start of the second slicing operator [1, 0, 3, 0, 5, 6, 7, 8, 9, 0]
output:
x = 1030567890
a = 103
b = 56
c = 7890
Thank you