Scope of a class..help???

lokeshkoppaka at gmail.com lokeshkoppaka at gmail.com
Thu May 23 05:51:36 EDT 2013


i had written the following code i am unable to create the instance of the class "Node" in the method "number_to_LinkedList" can any one help me how to do ??
and what is the error??
  

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



def number_to_LinkedList(numbers):
      pass
      list_numbers = list(numbers)
      head_node = Node() #unable to create the instance saying UnboundedLocal
      head_node.value = list_numbers[0]
      head_node.next = None
      current_node = head_node
      for i in range(1,len(list_numbers)):
        new_node = Node()
        new_node.value = list_numbers[i]
        new_node.next = current_node
        current_node = new_node
      current_node.next = None
      while Node:
        print Node.data
        Node = Node.next



More information about the Python-list mailing list