Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 18, 2019 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/3087541ffc45b612f4487bab782c9b5d to your computer and use it in GitHub Desktop.
Save parzibyte/3087541ffc45b612f4487bab782c9b5d to your computer and use it in GitHub Desktop.
Comprobar si tiene únicamente un punto created by parzibyte - https://repl.it/@parzibyte/Comprobar-si-tiene-unicamente-un-punto
def tiene_exactamente_un_punto(numero):
numero = str(numero)
primer_indice = numero.find(".")
if primer_indice is -1:
return False
return primer_indice is numero.rfind(".")
pruebas = ["1.2", "1", "1.1.2", "500", "5.0"]
for dato in pruebas:
print("¿'{}' tiene exactamente un punto? {}".format(dato, tiene_exactamente_un_punto(dato)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment