Skip to content

Instantly share code, notes, and snippets.

@Tremeschin
Last active March 1, 2025 10:19
Show Gist options
  • Save Tremeschin/ad9995a4c72886e85d2f7b1f3e6994e2 to your computer and use it in GitHub Desktop.
Save Tremeschin/ad9995a4c72886e85d2f7b1f3e6994e2 to your computer and use it in GitHub Desktop.
8 lines hangman in Python
import random as r
w=r.choice(input("enter csv of words: ").split(","))
d,t,a=["_"for n in w],5,[]
while t>0:
exit(w)if''.join(d)==w else print(''.join(d))
c=input(f"{t}t:")
for p in[p for p,v in enumerate(w)if c==v]:d[p]=w[p]
t-=0 if c in w else 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment