Created
October 22, 2021 20:12
-
-
Save lwiecek/9da4f5b1b636d2b7ad7baefcce35f9dc to your computer and use it in GitHub Desktop.
Enter password with attempts counter - one line
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
from itertools import takewhile, count; list(takewhile(lambda x: x[1] != 'password' and not print(f"wrong password. attempt {x[0]}"), ((i, input('enter password: ')) for i in count(1)))) == 1 or print('access granted') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment