Tell me please
Also what does t-=1 means if t is a variable
The len() function in Python returns you the number of elements in case of a list and returns the number of characters in case of a string.
$>>> A = [1, 2, 'a', 4, 10000]
$>>> len(A) = 3 #Number of elements in the list
$>>> string = 'Code Chef'
$>>> len(string) = 9 #Number of characters including space
t-=1 is the short notation for t = t - 1
len(A)=5
not 3
.
@swetankmodi That’s technically not true. -=
(__isub__
) and -
(__sub__
) doesn’t have to be compatible with each other. I don’t know of a case in the standard libraries where it isn’t, but for the case of addition (+=
and +
) types like list behaves differently (+
combines into a new list, +=
is the same as extend). Similar things are true for |
and &
for set operations.
2 Likes