Listing 06-09: Sequential Search

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 06\06.09 - Sequential Search.py
# Description: Sequential Search
##############################################################################

L = [15, 7, 27, 39]
p = int (input("Enter the value to search for:"))
found = False
x = 0
while x < len(L):
    if L[x] == p:
        found = True
        break
    x += 1
if found:
    print(f"{p} found at position {x}")
else:
    print(f"{p} not found")
Click here to download the file