Apologies for the multiple responses @SethMiller2
I believe I understand your intentions better now.
If you do want to specifically require capitalization for proper nouns you can leave your code as it was when it started, except just changeif frfrc not in answer:
to if frfrc not in answer.lower():
import random
import sys
import time
from inputimeout import inputimeout
dictionaryf = []
with open("Dictionary.txt") as f:
for line in f:
dictionaryf.append(line.strip())
debuglist = ['apple','green','red','education']
words = ["Welcome"]
timesUp = False
for typing in words[0]:
time.sleep(0.07)
sys.stdout.write(typing)
sys.stdout.flush()
time.sleep(0.5)
words = [" to..."]
for typing in words[0]:
time.sleep(0.07)
sys.stdout.write(typing)
sys.stdout.flush()
time.sleep(0.5)
print('')
words = [f"WORD BOMB!!!!"]
for typing in words[0]:
time.sleep(0.07)
sys.stdout.write(typing)
sys.stdout.flush()
time.sleep(0.5)
print("")
wordList = []
time.sleep(1)
def word_bomb_game():
print("nonono")
def game():
global answer
global frfrc
rc = ['ab', 'ac', 'ad', 'af', 'ag', 'ah', 'aj', 'ak', 'al', 'am', 'an', 'ap', 'aq', 'ar', 'as', 'at', 'av', 'aw', 'ax', 'ay', 'eb', 'ec', 'ed', 'ef', 'eg', 'eh', 'ej', 'ek', 'el', 'em', 'en', 'ep', 'eq', 'er', 'es', 'et', 'ev', 'ew', 'ex', 'ey', 'ib', 'ic', 'id', 'if', 'ig', 'ih', 'ij', 'ik', 'il', 'im', 'in', 'ip', 'ir', 'is', 'it', 'ob', 'oc', 'od', 'of', 'og', 'oh', 'ok', 'ol', 'om', 'on', 'op', 'or', 'os', 'ot', 'ov', 'ow', 'ox', 'oy', 'ub', 'uc', 'ud', 'uf', 'ug', 'uh', 'uk', 'ul', 'um', 'un', 'up', 'ur', 'us', 'ut', 'uv', 'uw', 'ux', 'uy']
debugrc = ['ap','ed','re']
frfrc = random.choice(rc)
print(f'TYPE A WORD WITH "{frfrc.upper()}"')
# first, we get user input
try:
answer = ''
answer = inputimeout(prompt='>', timeout=10)
answer = str(answer)
print(f'"{answer}"')
checkAnswer()
except Exception:
print("")
answer = 'TIMES UP!'
print(answer)
time.sleep(1)
print("NEXT PLAYER!")
print("")
time.sleep(1)
game()
def checkAnswer():
global dictionaryf
global answer
global frfrc
if frfrc not in answer.lower(): #this needs to be lowercase
print('')
print("WORD DOESN'T MATCH!")
time.sleep(1)
print("NEXT PLAYER!")
time.sleep(1)
print('')
game()
elif answer in wordList:
print('')
print('WORD ALREADY SAID!')
time.sleep(1)
print("NEXT PLAYER!")
time.sleep(1)
print('')
game()
elif answer in dictionaryf:
wordList.append(answer)
congratsmsg = ['AMAZING', 'WONDERFUL', 'GOOD', 'GREAT']
cmsg = random.choice(congratsmsg)
print(f'{cmsg} JOB!')
time.sleep(1)
print('NEXT PLAYER!')
time.sleep(1)
print('')
game()
else:
print('')
print("THAT'S NOT A WORD, LOL!")
time.sleep(1)
print("NEXT PLAYER!")
time.sleep(1)
print('')
game()
time.sleep(0.5)
print('')
print('type "start" to play')
print('type "settings" to open settings')
print('')
def startinput():
strt = input('> ')
if "start" not in strt:
print(f'Error: Unknown Command: "{strt}"')
startinput()
else:
game()
startinput()
The only thing that needs to be changed is if frfrc not in answer:
specifically in the case where the two letters it gives you happens to be both the first two letters of the word AND the first letter is capitalized.
In this corrected version, if you do capitalize a word that isn’t a proper noun, it will count as wrong, and if you don’t capitalize a word that is a proper noun it will also count as wrong.
But this will correct the error, where if the two letters you are given, (TYPE A WORD WITH “AT”), which is really “at”, are the first two letters of a proper noun, and thus are capitalized, (like in Atari) , it will still pass if frfrc not in answer.lower():
, since we are checking if at is in atari instead of Atari, regardless of how the user typed it in.
I think this is closer to what you want?