Skip to content

Instantly share code, notes, and snippets.

@Tremeschin
Last active September 20, 2020 07:41
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
@Tremeschin
Copy link
Author

Technically line 2 w=r.choice(input().split(",")) is illegal as we have to provide a csv for the words database in the game llike: word1,word2,word3,word4 after starting the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment