adventjs-issues icon indicating copy to clipboard operation
adventjs-issues copied to clipboard

Challenge 7 Python packages.reverse is not a function

Open mrey-profe opened this issue 1 year ago • 1 comments

For challenge 7. This solucion returns: TypeError: packaged.reverse is not a function. It works when executed directly on the Python Interpreter:

def fixPackages(packages):
  def fix_intern(packages):
      try:
        inicio = packages.index("(")
        fin = packages.rindex(")")
        arreglada = fix_intern(packages[inicio+1:fin])
        packages = packages[:inicio] + arreglada + packages[fin+1:]
      except: # No quedan más
        return packages[::-1]
      return packages[::-1]

    try:
      inicio = packages.index("(")
      fin = packages.rindex(")")
      arreglada = fix_intern(packages[inicio+1:fin])
      packages = packages[:inicio] + arreglada + packages[fin+1:]
    except: # No quedan más
      return packages[::-1]
    return packages

mrey-profe avatar Dec 08 '24 16:12 mrey-profe

Got the same error on a previous challenge but I fixed doing the same as you did, reverse it using slices.

jdelarubia avatar Dec 08 '24 22:12 jdelarubia