Created
January 18, 2019 18:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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