【发布时间】:2020-11-12 13:52:15
【问题描述】:
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.")
我说的是第一个 if 语句,我怎么不 == random_choice ??? 所以我想如果 word_pick 不在 random_choice 中,则将分数减去 5
请帮助
【问题讨论】:
标签: python-3.x random guess.js