On creating a
list in python with just one element, when I try to get the -1 index element instead of
getting list index out range error it is giving the 0th
element.
some =
['something']
print(some[0]) # prints something
print(some[-1]) #
prints
something
Here
is a link to the same:
href="https://repl.it/@hearsid/SuperiorProudShoutcast" rel="nofollow
noreferrer">https://repl.it/@hearsid/SuperiorProudShoutcast
href="https://i.stack.imgur.com/Ld2UH.png" rel="nofollow noreferrer"> src="https://i.stack.imgur.com/Ld2UH.png" alt="enter image description
here">
No comments:
Post a Comment