Join the discussion
Ask questions, share your code and help other Python learners. It's free.
Log in to comment, vote and follow discussions.
Continue with Google
or
Already have an account?
New to Space Python?
Check your inbox
We sent an activation link to . Open it in this browser and you'll come straight back here, logged in.
Nothing after a few minutes? Check your spam folder.
Comments 4
Join the discussion CommentAlready have an account? Log in
Indexes start at 0, so five items have indexes 0–4. Index 5 would be a sixth item. For "the last one" regardless of length, use a negative index.
-1 works for any list length. Got it.
And for an even number of items there's no single middle. Statistics module's median handles it.
Stage 3's middle with
len(readings) // 2is a nice touch — for 5 items that's index 2, the real middle.