You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
action_accept = ["run", "jump"]
# Validación de las acciones
if not all(a in action_accept for a in action):
raise ValueError(
"Las acciones solo pueden ser 'run' o 'jump'"
) # Raise detiene la ejecución del programa
pista_list = list(pista)
path = []
for i, j in zip(action, pista_list):
# Si el/a atleta hace "run" en "_" (suelo) y "jump" en "|" (valla) será correcto.
if i == "jump" and j == "|":
path.append("|")
if i == "run" and j == "_":
path.append("_")
# Si hace "run" en "|" (valla), se variará la pista por "/".
if i == "run" and j == "|":
path.append("/")
# Si hace "jump" en "_" (suelo), se variará la pista por "x".
if i == "jump" and j == "_":
path.append("x")
if ("x" or "/") in path:
return print(path)
else:
return print("Se ha superado la pista con exito")
`def race(action: [], pista: str):
Pruebas
try:
race(["run", "jump", "run", "run", "run", "jump", "run", "jump"], "|__|||")
race(["run", "jump", "pedro", "run", "run", "jump", "run", "jump"], "|__|||")
race(["run", "jump", "run", "run"], "_|__")
except ValueError as e:
print(f"Error: {e}")
`
The text was updated successfully, but these errors were encountered: