class Node(object):
	def __init__(self, data):
		self.data = data
		self.next = None

class LinkedList(object):
	def __init__(self, head=None):
		self.head = head

	def add(self, new_node):
		current_node = self.head
		if self.head:
			while current_node.next:
				current_node = current_node.next
			current_node.next = new_node # add to end of linked list
		else:
			self.head = new_node

class Node(object):
	def __init__(self, data):
		self.data = data
		self.next = None

class LinkedList(object):
	def __init__(self, head=None):
		self.head = head

	def add(self, new_node):
		current_node = self.head
		if self.head:
			while current_node.next:
				current_node = current_node.next
			current_node.next = new_node # add to end of linked list
		else:
			self.head = new_node

	def search(self, position):
		counter = 1
		current_node = self.head
		if position < 1:
			return None
		while current_node and counter <= position: # go through linked list until you reach input position
			if counter == position:
				return current_node
			current_node = current_node.next
			counter += 1
		return None # if position larger than length of linked list












Add search method for python linked list implementation
Add search method for python linked list implementation

  class Node(object):
  	def __init__(self, data):
  		self.data = data
  		self.next = None
  
  class LinkedList(object):
  	def __init__(self, head=None):
  		self.head = head
  
  	def add(self, new_node):
  		current_node = self.head
  		if self.head:
  			while current_node.next:
  				current_node = current_node.next
  			current_node.next = new_node # add to end of linked list
  		else:
  			self.head = new_node
  
+ 	def search(self, position):
+ 		counter = 1
+ 		current_node = self.head
+ 		if position < 1:
+ 			return None
+ 		while current_node and counter <= position: # go through linked list until you reach input position
+ 			if counter == position:
+ 				return current_node
+ 			current_node = current_node.next
+ 			counter += 1
+ 		return None # if position larger than length of linked list
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Add search method for python linked list implementation
## Code Before:
class Node(object):
	def __init__(self, data):
		self.data = data
		self.next = None

class LinkedList(object):
	def __init__(self, head=None):
		self.head = head

	def add(self, new_node):
		current_node = self.head
		if self.head:
			while current_node.next:
				current_node = current_node.next
			current_node.next = new_node # add to end of linked list
		else:
			self.head = new_node

## Instruction:
Add search method for python linked list implementation
## Code After:
class Node(object):
	def __init__(self, data):
		self.data = data
		self.next = None

class LinkedList(object):
	def __init__(self, head=None):
		self.head = head

	def add(self, new_node):
		current_node = self.head
		if self.head:
			while current_node.next:
				current_node = current_node.next
			current_node.next = new_node # add to end of linked list
		else:
			self.head = new_node

	def search(self, position):
		counter = 1
		current_node = self.head
		if position < 1:
			return None
		while current_node and counter <= position: # go through linked list until you reach input position
			if counter == position:
				return current_node
			current_node = current_node.next
			counter += 1
		return None # if position larger than length of linked list











