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?
MaxManus
0
Newbie Poster
Recommended Answers
Jump to Postfor f in arr: if f > 100: return f
Is that what you wanted?
Jump to PostA 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.
All 5 Replies
scru
909
Posting Virtuoso
Featured Poster
woooee
814
Nearly a Posting Maven
MaxManus
0
Newbie Poster
woooee
814
Nearly a Posting Maven
scru
909
Posting Virtuoso
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.