From 33237f7d84ecd4979d220af273190a37533d4431 Mon Sep 17 00:00:00 2001 From: Ananthakrishnan Nair RS <61831021+akrish4@users.noreply.github.com> Date: Wed, 16 Dec 2020 19:41:12 +0530 Subject: [PATCH] added python topic --- SEARCHING/python/linea_search.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 SEARCHING/python/linea_search.py diff --git a/SEARCHING/python/linea_search.py b/SEARCHING/python/linea_search.py new file mode 100644 index 00000000..ded48038 --- /dev/null +++ b/SEARCHING/python/linea_search.py @@ -0,0 +1,12 @@ +def linear_search(a, x): + for i in range(len(a)): + if a[i] == x: + return i + return -1 + +a = [1,4,7,9,14,17,39,56] +x = 8 +y = 39 + +print(linear_search(a,x)) +print(linear_search(a,y))