Challenge: Password Attempts
Завдання
Swipe to start coding
Strengthen your while loop skills by building a password entry system. Complete the following steps:
- Use a while loop to process password attempts, stopping if the correct password is entered or if the maximum number of attempts is reached.
- Try not use
if,else, orbreakstatements inside the loop. - On each attempt, print the password entered.
- Print a message showing how many attempts remain after each incorrect guess.
- When the correct password is entered, print a success message and stop further attempts.
- If all attempts are used without entering the correct password, print an account locked message after the loop.
Рішення
Note
In this task:
attemptis the current password guess from theattemptsarray, used for printing and comparison;remainingcounts how many tries are left, decreasing after each wrong password;foundistruewhen the correct password is entered, stopping the loop.
These variables let you manage attempts and stop the loop without using if, else, or break.
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 2
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 5.56
Challenge: Password Attempts
Свайпніть щоб показати меню
Завдання
Swipe to start coding
Strengthen your while loop skills by building a password entry system. Complete the following steps:
- Use a while loop to process password attempts, stopping if the correct password is entered or if the maximum number of attempts is reached.
- Try not use
if,else, orbreakstatements inside the loop. - On each attempt, print the password entered.
- Print a message showing how many attempts remain after each incorrect guess.
- When the correct password is entered, print a success message and stop further attempts.
- If all attempts are used without entering the correct password, print an account locked message after the loop.
Рішення
Note
In this task:
attemptis the current password guess from theattemptsarray, used for printing and comparison;remainingcounts how many tries are left, decreasing after each wrong password;foundistruewhen the correct password is entered, stopping the loop.
These variables let you manage attempts and stop the loop without using if, else, or break.
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 2
single