def contrasenya(password): validar=False long=len(password) espacio=False mayuscula=False minuscula=False numeros=False y=password.isalnum() correcto=True for carac in password: if carac.isspace()==True: espacio=True if carac.isupper()== True: mayuscula=True if carac.islower()== True: minuscula=True if carac.isdigit()== True: numeros=True if espacio==True: print("La contraseña no puede contener espacios") else: validar=True if long <8 and validar==True: print("Mínimo 8 caracteres") validar=False if mayuscula == True and minuscula ==True and numeros == True and y== False and validar ==True: validar = True else: correcto=False if validar == True and correcto==False: print("La contraseña elegida no es segura: debe contener letras minúsculas, mayúsculas, números y al menos 1 carácter no alfanumérico") if validar == True and correcto ==True: return True password = raw_input('Introduce una contraseña: ') contrasenya(passwd)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question