Listing 08-01: Search in a list

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 08\08.01 - Search in a list.py
# Description: Search in a list
##############################################################################

def search(where, value):
    for x, e in enumerate(where):
        if e == value:
            return x
    return None
L = [10, 20, 25, 30]
print(search(L, 25))
print(search(L, 27))
Click here to download the file