How do we skip to the last element in python?
ITS CLEAR NOW!!!!!!!!!!!!
So for example i have a list
foo = ['hello', 'world','how']
And, I have this loop
for i in foo:
----------Codes to skip to last element.--------
therefore, variable 'i' becomes the last element in foo, which is 'how'.
if i == 'how':
print 'success!'
And yes, i was wondering if there is any method to do so in a for loop, not outside.
The closest I have found is this:
Python skipping last element in while iterating a list using for loop
Please add in the explanation for your answers on how it works.
Edit: Also, if it's not possible, please explain why(optional).