title: TypeError: 'bool' object is not subscriptable: Greedy Best First Search
body: <p>I am coding Greedy Best First Search Algorithm in Python, and this is the error that I am getting.</p>
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-4-7cb06a2b610d&gt; in &lt;module&gt;
       41 source = 0
       42 target = 9
  ---&gt; 43 best_first_search(source, target, v)
  
  &lt;ipython-input-4-7cb06a2b610d&gt; in best_first_search(source, target, n)
       15 
       16         for v, c in graph[u]:
  ---&gt; 17             if visited[v] == False:
       18                 visited[v] = True
       19                 pq.put((c, v))
  
  TypeError: 'bool' object is not subscriptable
  </code></pre>
  <p>Greedy Best First Search is basically a combination of DFS and BFS using the PriorityQueue library i am trying to get the one with the lower score.
  My code is:</p>
  <pre><code>from queue import PriorityQueue
  v = 14
  graph = [[] for i in range(v)]
   
  def best_first_search(source, target, n):
      visited = [0] * n
      visited = True
      pq = PriorityQueue()
      pq.put((0, source))
      while pq.empty() == False:
          u = pq.get()[1]
          print(u, end=&quot; &quot;)
          if u == target:
              break
   
          for v, c in graph[u]:
              if visited[v] == False:
                  visited[v] = True
                  pq.put((c, v))
      print()
  
  def addedge(x, y, cost):
      graph[x].append((y, cost))
      graph[y].append((x, cost))
  
      
  addedge(0, 1, 3)
  addedge(0, 2, 6)
  addedge(0, 3, 5)
  addedge(1, 4, 9)
  addedge(1, 5, 8)
  addedge(2, 6, 12)
  addedge(2, 7, 14)
  addedge(3, 8, 7)
  addedge(8, 9, 5)
  addedge(8, 10, 6)
  addedge(9, 11, 1)
  addedge(9, 12, 10)
  addedge(9, 13, 2)
   
  source = 0
  target = 9
  best_first_search(source, target, v)
  </code></pre>
  <p>Plz suggest a way to get the error out</p>