{"id":1036,"date":"2020-06-10T17:20:46","date_gmt":"2020-06-10T17:20:46","guid":{"rendered":"https:\/\/www.projectimmerse.com\/blog\/?p=1036"},"modified":"2020-06-15T01:27:21","modified_gmt":"2020-06-15T01:27:21","slug":"linear-linked-list-search-element-using-python","status":"publish","type":"post","link":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/","title":{"rendered":"Linear Linked List &#8211; Search Element using Python"},"content":{"rendered":"<p>What&#8217;s up friends?!?<\/p>\n<p>Let&#8217;s continue on another linear linked list problem. I&#8217;m going to make this post short since I&#8217;ll use the boilerplate code from the last LLL problem we had. If you need any help, I&#8217;ll also post the link to GitHub so you can stroll along.<\/p>\n<p>Anyways, for this problem, I just want to write some code to find a specific element inside the LLL. You could do this iteratively or recursively, whichever way you choose to do, but for the purpose of this program, I am just going to solve it iteratively.<\/p>\n<p><!--more--><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n    # searching iteratively function\r\n    def searchElement(self, number):\r\n\r\n    # default case if there's no list in the first place\r\n    if not self.head:\r\n        return False\r\n\r\n    current = self.head\r\n\r\n    # going through the linked list\r\n    while current is not None:\r\n        if current.data == number:\r\n            return True\r\n        current = current.next\r\n\r\n    return False\r\n<\/pre>\n<p>I&#8217;d say the most important here is to notice how I used the while loop to go through each of the node, and use the pointers to point to the next node. It would exit out of the loop if the data of the current node doesn&#8217;t exist.<\/p>\n<p>Well, if you have any question, feel free to ask and have a great day.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What&#8217;s up friends?!? Let&#8217;s continue on another linear linked list problem. I&#8217;m going to make this post short since I&#8217;ll use the boilerplate code from the last LLL problem we had. If you need any help, I&#8217;ll also post the link to GitHub so you can stroll along. Anyways, for this problem, I just want &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Linear Linked List &#8211; Search Element using Python&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1065,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[41,39],"class_list":["post-1036","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-fundamentals","tag-data-structures","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Linear Linked List - Search Element using Python - Project Immerse<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linear Linked List - Search Element using Python - Project Immerse\" \/>\n<meta property=\"og:description\" content=\"What&#8217;s up friends?!? Let&#8217;s continue on another linear linked list problem. I&#8217;m going to make this post short since I&#8217;ll use the boilerplate code from the last LLL problem we had. If you need any help, I&#8217;ll also post the link to GitHub so you can stroll along. Anyways, for this problem, I just want &hellip; Continue reading &quot;Linear Linked List &#8211; Search Element using Python&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Project Immerse\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-10T17:20:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-15T01:27:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2020\/06\/linear-linked-list-search-element-using-python.png\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"532\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Alex Mercer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alex Mercer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/\"},\"author\":{\"name\":\"Alex Mercer\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"headline\":\"Linear Linked List &#8211; Search Element using Python\",\"datePublished\":\"2020-06-10T17:20:46+00:00\",\"dateModified\":\"2020-06-15T01:27:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/\"},\"wordCount\":224,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/linear-linked-list-search-element-using-python.png\",\"keywords\":[\"data structures\",\"python\"],\"articleSection\":[\"Programming Fundamentals\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/\",\"name\":\"Linear Linked List - Search Element using Python - Project Immerse\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/linear-linked-list-search-element-using-python.png\",\"datePublished\":\"2020-06-10T17:20:46+00:00\",\"dateModified\":\"2020-06-15T01:27:21+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/linear-linked-list-search-element-using-python.png\",\"contentUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/linear-linked-list-search-element-using-python.png\",\"width\":750,\"height\":532,\"caption\":\"Linear Linked List using Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/linear-linked-list-search-element-using-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linear Linked List &#8211; Search Element using Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/\",\"name\":\"Project Immerse\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\",\"name\":\"Alex Mercer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/alex-mercer-author-150x150.png\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/alex-mercer-author-150x150.png\",\"contentUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/alex-mercer-author-150x150.png\",\"caption\":\"Alex Mercer\"},\"description\":\"Alex Mercer is a writer and contributor at Project Immerse, covering web design, WordPress, web development, SEO, digital strategy, emerging technology, and the evolving world of the web. His work focuses on practical ideas, useful tools, and approachable guidance that help creators, developers, and business owners build better digital experiences. Alex writes with a hands-on, curiosity-driven approach, exploring both established web practices and new technologies shaping how websites are designed, built, and discovered.\",\"sameAs\":[\"https:\\\/\\\/www.projectimmerse.com\"],\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/author\\\/projectimmerse\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linear Linked List - Search Element using Python - Project Immerse","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/","og_locale":"en_US","og_type":"article","og_title":"Linear Linked List - Search Element using Python - Project Immerse","og_description":"What&#8217;s up friends?!? Let&#8217;s continue on another linear linked list problem. I&#8217;m going to make this post short since I&#8217;ll use the boilerplate code from the last LLL problem we had. If you need any help, I&#8217;ll also post the link to GitHub so you can stroll along. Anyways, for this problem, I just want &hellip; Continue reading \"Linear Linked List &#8211; Search Element using Python\"","og_url":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/","og_site_name":"Project Immerse","article_published_time":"2020-06-10T17:20:46+00:00","article_modified_time":"2020-06-15T01:27:21+00:00","og_image":[{"width":750,"height":532,"url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2020\/06\/linear-linked-list-search-element-using-python.png","type":"image\/png"}],"author":"Alex Mercer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Alex Mercer","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#article","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/"},"author":{"name":"Alex Mercer","@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"headline":"Linear Linked List &#8211; Search Element using Python","datePublished":"2020-06-10T17:20:46+00:00","dateModified":"2020-06-15T01:27:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/"},"wordCount":224,"commentCount":0,"image":{"@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2020\/06\/linear-linked-list-search-element-using-python.png","keywords":["data structures","python"],"articleSection":["Programming Fundamentals"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/","url":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/","name":"Linear Linked List - Search Element using Python - Project Immerse","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#primaryimage"},"image":{"@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2020\/06\/linear-linked-list-search-element-using-python.png","datePublished":"2020-06-10T17:20:46+00:00","dateModified":"2020-06-15T01:27:21+00:00","author":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"breadcrumb":{"@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#primaryimage","url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2020\/06\/linear-linked-list-search-element-using-python.png","contentUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2020\/06\/linear-linked-list-search-element-using-python.png","width":750,"height":532,"caption":"Linear Linked List using Python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.projectimmerse.com\/blog\/linear-linked-list-search-element-using-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.projectimmerse.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Linear Linked List &#8211; Search Element using Python"}]},{"@type":"WebSite","@id":"https:\/\/www.projectimmerse.com\/blog\/#website","url":"https:\/\/www.projectimmerse.com\/blog\/","name":"Project Immerse","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.projectimmerse.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5","name":"Alex Mercer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2026\/09\/alex-mercer-author-150x150.png","url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2026\/09\/alex-mercer-author-150x150.png","contentUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2026\/09\/alex-mercer-author-150x150.png","caption":"Alex Mercer"},"description":"Alex Mercer is a writer and contributor at Project Immerse, covering web design, WordPress, web development, SEO, digital strategy, emerging technology, and the evolving world of the web. His work focuses on practical ideas, useful tools, and approachable guidance that help creators, developers, and business owners build better digital experiences. Alex writes with a hands-on, curiosity-driven approach, exploring both established web practices and new technologies shaping how websites are designed, built, and discovered.","sameAs":["https:\/\/www.projectimmerse.com"],"url":"https:\/\/www.projectimmerse.com\/blog\/author\/projectimmerse\/"}]}},"_links":{"self":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/1036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/comments?post=1036"}],"version-history":[{"count":9,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/1036\/revisions"}],"predecessor-version":[{"id":1058,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/1036\/revisions\/1058"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/media\/1065"}],"wp:attachment":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/media?parent=1036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/categories?post=1036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/tags?post=1036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}