I have some basic code that I'm not grasping the behaviour of:
L = [ 'a', 'bb', 'ccc' ]
L.append(range(2))
print len(L)
print len(L + range(1))
print len(L)
The output of which is
4
5
4
This is confusing to me, as my thought process is that the length of the initial list is 3, and appending range(2)
to the end brings it to length of 5. Therefore I'd expect the output to be 5 6 5
. I'm sure it's a simple quirk, but I'm a bit lost and having a hell of a time trying to find an answer online. Would anyone be able to point me in the right direction?