title: How to change from Yield to return with loop?
body: <p>I'm doing a code project about resolving labyrinth, I'm using DFS algorithm to find a path from a starting point to a target point.</p>
  <p>I've two sections of code, one with 'Yield' which I'm not authorize to use, and other but it sends a bool, I don't know how to get the path.</p>
  <p>The first code:</p>
  <pre><code>def dfs_paths(self, start, target, path=None):
      if path is None:
          path = [start]
      if start == target:
          yield path
      for next in self.mazegrid.adjacency[start] - set(path):
          yield from self.dfs_paths(next, target, path + [next])
  </code></pre>
  <p>My question is: How to change this code from 'Yield' and 'Yield from' to return with loop?</p>
  <p>The second code:</p>
  <pre><code>  def explorepath (self, current, objective, visited_list, path) : 
      
      if current == objective : 
          return True
      if current in visited_list : 
          return False 
      visited_list.append(current)
      path.append(current)
      
      for neighbor in self.mazegrid.successors(current): 
          if self.explorepath(neighbor, objective, visited_list, path) == True : 
              return True
          path.remove(current)
          return False
  </code></pre>
  <p>I know that the path is stocked in: path, but I don't know how to get it?</p>