Skip to content

Instantly share code, notes, and snippets.

@dcshapiro
Created February 16, 2021 23:43
Show Gist options
  • Save dcshapiro/33e500094d531c0c01c5cb2afdb80fdd to your computer and use it in GitHub Desktop.
Save dcshapiro/33e500094d531c0c01c5cb2afdb80fdd to your computer and use it in GitHub Desktop.
!wget https://github.com/dwyl/english-words/raw/master/words_alpha.txt
fileid="0ByS1YeQOURTJS0VtRnFQc1pkczQ"
!wget --no-check-certificate 'https://docs.google.com/uc?export=download&id={fileid}' -O fakewords.txt
from IPython.display import clear_output
import random
with open("words_alpha.txt","r") as real:
realWords=real.read().split("\n")
with open("fakewords.txt","r") as fake:
fakeWords=fake.read().split("\n")
while True:
truth=random.choice([True,False])
if truth:
mysteryWord=random.choice(realWords)
else:
mysteryWord=random.choice(fakeWords)
print(mysteryWord,": Is this a real word?? Type any of these: [R,r,T,t] for REAL. [F,f, or any other choice] means FAKE.")
myChoice=input()
clear_output()
chosen=myChoice.lower() in ["r","t"]
label={True:"REAL",False:"FAKE"}
if (chosen and truth) or (not truth and not chosen):
print("RIGHT!",mysteryWord,"is",label[truth])
else:
print("WRONG!",mysteryWord,"is",label[truth],"but you said",label[chosen])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment