Skip to content

Commit

Permalink
Merge pull request #5154 from marcoatrs/main
Browse files Browse the repository at this point in the history
Reto #28 - Python
  • Loading branch information
Roswell468 authored Sep 30, 2023
2 parents 2820a23 + 3e2833f commit b7f575b
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
signos_permitidos = "0123456789+-/*% "
parejas_invalidas = ["*/", "/*", "%/", "/%", "*%", "%*", "%%", "+/", "-/"]


def expresion_matematica(expresion: str) -> bool:
# Caracter invalido
for c in expresion:
if c not in signos_permitidos:
return False
# Signos dobles
expresion = expresion.replace(" ", "")
for par in parejas_invalidas:
if par in expresion:
return False
return True

print(expresion_matematica("2 + 4"))
print(expresion_matematica("2 + /4"))
print(expresion_matematica("2 +y 4"))

0 comments on commit b7f575b

Please sign in to comment.