import random
import time
import sys
from colored import fg
color1 = fg("red")
color2 = fg("blue")
color3 = fg("green")
color4 = fg("yellow")
for x in (color1 + "Hi,\nThis is a word guessing game, you will have to guess the answer from 100 words.\nYou will have 45 chances to guess the number. You initially start with 225 points. Every chance you enter the wrong answer, you lose 5 points. The quicker you guess, the higher your score(225 is the highest score you can have).\n\n"):
sys.stdout.write(x)
sys.stdout.flush()
time.sleep(0.03)
words = ['time', 'year', 'people', 'way', 'day', 'man', 'thing', 'woman', 'life', 'child', 'world', 'school', 'state', 'family', 'student', 'group', 'country', 'problem', 'hand', 'part', 'place', 'case', 'week', 'company', 'system', 'program', 'question', 'work', 'government', 'number', 'night', 'point', 'home', 'water', 'room', 'mother', 'area', 'money', 'story', 'fact', 'month', 'lot', 'right', 'study', 'book', 'eye', 'job', 'word', 'business', 'issue', 'side', 'kind', 'head', 'house', 'service', 'friend', 'father', 'power', 'hour', 'game', 'line', 'end', 'member', 'law', 'car', 'city', 'community', 'name', 'president', 'team', 'minute', 'idea', 'kid', 'body', 'information', 'back', 'parent', 'face', 'others', 'level', 'office', 'door', 'health', 'person', 'art', 'war', 'history', 'party', 'result', 'change', 'morning', 'reason', 'research', 'girl', 'guy', 'moment', 'air', 'teacher', 'force', 'education']
for x in (color2+ f"These are the words in the list you can pick from:\n\n{color3}'time', 'year', 'people', 'way', 'day', 'man', 'thing', 'woman', 'life', 'child', 'world', 'school', 'state', 'family', 'student', 'group', 'country', 'problem', 'hand', 'part', 'place', 'case', 'week', 'company', 'system', 'program', 'question', 'work', 'government', 'number', 'night', 'point', 'home', 'water', 'room', 'mother', 'area', 'money', 'story', 'fact', 'month', 'lot', 'right', 'study', 'book', 'eye', 'job', 'word', 'business', 'issue', 'side', 'kind', 'head', 'house', 'service', 'friend', 'father', 'power', 'hour', 'game', 'line', 'end', 'member', 'law', 'car', 'city', 'community', 'name', 'president', 'team', 'minute', 'idea', 'kid', 'body', 'information', 'back', 'parent', 'face', 'others', 'level', 'office', 'door', 'health', 'person', 'art', 'war', 'history', 'party', 'result', 'change', 'morning', 'reason', 'research', 'girl', 'guy', 'moment', 'air', 'teacher', 'force', 'education' \n\n\n"):
sys.stdout.write(x)
sys.stdout.flush()
time.sleep(0.01)
time.sleep(2)
word_pick = input(color4 + "Pick a random word from the above list: ")
random_choice = random.choice(words)
chances = 45
score = 225
if word_pick.upper() or word_pick.lower() or word_pick.title() not random_choice:
print("Congrats, you have picked the right word.")
if word_pick.upper() or word_pick.lower() or word_pick.title() == random_choice:
print("Congrats, you have picked the right word.")
I am talking about the first if statement, how do i do not == random_choice ??? So i wanna do if word_pick is not in random_choice, then minus the score by 5
PLZ HELPP
I suggest either only checking for the lowercase version of the word, or checking strictly.
PENALTY = 5
if word_pick.lower() == random_choice:
# guess is right
print("Congrats")
else:
# guess isn't right
print("You have failed")
score -= PENALTY
If you want to test all possible versions separately, you can put them into a list and use the in
operator.
if random_choice in [word_pick.lower(), word_pick.upper(), word_pick.title()]:
# guess is right