This somewhat depends on the context, but it effectively means “the element of the variable ‘filename’ at the fourth position from the end.”
So, if filename
is a string with the value of 'Test string.'
then filename[-4]
will be 'i'
.
In this particular case, the expression would evaluate to False
, because “i” is not “B”.
1
solved python assistance with ‘if filename[-4]==”B” ‘ [closed]