Skip to content

Find the position

Find the position

Search a list and report where something is, counting from 0.

Loop over the positions with range(len(items)), so you have the index i as well as the item items[i]. return leaves the function straight away, which is exactly what you want at the first match. Return -1 only after the loop has checked every item.

Log in or create account

IGCSE, A-Level & AP