I have a issue with python.
I make a simple list:
>>> my_list = ["one","two","three"]
I want create a "single line code" for find a string.
for example, I have this code:
>>> [(i) for i in my_list if i=="two"]
['two']
But when I watch the variable is wrong (I find the last value of my list):
>>> print i
three
Why does my variable contain the last element and not the element that I want to find?
question from:https://stackoverflow.com/questions/32580489/python-for-and-if-on-one-line