Skip to content

Instantly share code, notes, and snippets.

@lwiecek
Created October 22, 2021 20:12
Show Gist options
  • Save lwiecek/9da4f5b1b636d2b7ad7baefcce35f9dc to your computer and use it in GitHub Desktop.
Save lwiecek/9da4f5b1b636d2b7ad7baefcce35f9dc to your computer and use it in GitHub Desktop.
Enter password with attempts counter - one line
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