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

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

	def push(self, newdata): #in front
		newnode = Node(newdata)
		newnode.next = self.head
		self.head = newnode

	def insertAfter(self, prevnode, newdata):
		newnode = Node(newdata)
		newnode.next = prevnode.next
		prevnode.next = newnode 

	def append(self, newdata): #at end
		newnode = Node(newdata)
		#if list is empty
		if self.head is None:
			self.head = newnode
			return
		#if not
		temp = self.head
		while(temp.next):
			temp = temp.next
		temp.next = newnode

	def deleteNode(self, key): #first one found
		temp = self.head

		while (temp is not None):
			print 'Now at:',temp.data
			if temp.data == key:
				print 'Found 3 at',temp.data
				break
			print 'prev is temp now'
			prev = temp
			temp = temp.next

		if(temp == None): return
		prev.next = temp.next
		temp = None

	def deletepos(self, pos): #specific position
		temp = self.head

		for i in xrange(0,pos-1):
			prev = temp
			temp = temp.next
	
		if(temp == None): return
		prev.next = temp.next
		temp = None

	def printList(self):
		temp = self.head
		while(temp):
			print " %d" %(temp.data)
			temp = temp.next

def main():
	print 'hello'
	ll = LinkedList()
	ll.push(1)
	ll.push(2)
	ll.push(3)
	ll.push(4)
	ll.push(5)
	print "Created Linked List: "
	ll.printList()
	ll.deletepos(3) 
	print "\nLinked List after Deletion of 3:"
	ll.printList()

if __name__ == '__main__':
	main()