Hey, I got an array with float values from 0 - 120. How can I find the first element over 100 and which element it is?
for f in arr: if f > 100: return f
Is that what you wanted?
A slight modification.
for index, item in enumerate(arr): if item > 100: return index, item
See here for info on lists http://effbot.org/zone/python-list.htm
Edit: Damn, this is probably homework. My mistake. Using enumerate will probably red flag it though.
Thanks, you saved my day.
Don't worry, your efforts weren't all wasted. I learned that enumerate thing from you, and I'm using it now to make my code look nicer. :)