Password Check
Keeps asking for a password until it has at least 8 characters.
- Level
- Beginner
- Topic:
- Loops
- Concepts:
- Input & output
- Repetir
- Text
Open in Codoritmo
Run, change and debug this example in your browser.
What you'll learn
Repetir ... Hasta Que runs the block at least once and asks again until the condition is met. Longitud counts the characters in a text.
Code
Algoritmo ValidarClave Definir clave Como Caracter Definir intentos Como Entero intentos <- 0 Repetir Escribir "Crea una contraseña (mínimo 8 caracteres):" Leer clave intentos <- intentos + 1 Si Longitud(clave) < 8 Entonces Escribir "Muy corta: tiene ", Longitud(clave), " caracteres." FinSi Hasta Que Longitud(clave) >= 8 Escribir "Contraseña aceptada en el intento ", intentos, "."FinAlgoritmoFlowchart
Each block in the flowchart matches one instruction in the code.
Sample run
This is what the program shows when it runs. The answers typed by the user are highlighted.
Crea una contraseña (mínimo 8 caracteres):User answer: gatoMuy corta: tiene 4 caracteres.Crea una contraseña (mínimo 8 caracteres):User answer: sol123Muy corta: tiene 6 caracteres.Crea una contraseña (mínimo 8 caracteres):User answer: miPerro2024Contraseña aceptada en el intento 3.
Challenge
Also reject the password "12345678".
Show hint
Join both conditions in the Hasta Que with Y.
Related examples
Reusable Validation
Validates the email and age on a sign-up form.
IntermediateContact Book
Add, list and search contacts in a book that grows.
AdvancedName Initials
Gets the initials of a full name.
Beginner