100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 一个倒吊人小游戏

一个倒吊人小游戏

时间:2021-10-13 16:01:04

相关推荐

一个倒吊人小游戏

# 把已知的提示显示出来def known_clues():global clues, letterclues.append(letter)return clues# 从单词列表中随机提取单词(顺便给word赋值)from random import randintdef get_index(list):index = randint(0, len(list)) # 随机生成 0-99 之间的数,包括 0 和 99word = list[index]first = word[0]return word, first# 判断字母是否在单词中+判断字母在单词中的哪个位置def whether_in():global letter, timesif letter in word:times = word.count(letter)print(f'恭喜你!!!该单词中有{times}个字母\"{letter}\"')find_location()# 调用函数_判断字母在单词中的哪个位置else:print(f'很遗憾,该单词中没有字母\"{letter}\"')known_clues()# 把该字母添加进已知的提示中# 判断字母在单词中的哪个位置def find_location():global times, letter, word_whileguess, winindex = -1# 防止位置在索引0word_whileguess = list(word_whileguess)# 把单词拆成列表方便修改for i in range(times):index = word.index(letter,index+1)print(f'在第{index+1}个位置')word_whileguess[index] = letter# 把原来没猜到的"-"改成字母# 把单词重新合并成字符串k = ''for i in word_whileguess:k += iword_whileguess = k# print(word_whileguess)if word_whileguess == word:win = Trueprint(f'恭喜你猜对了!!!该单词是:', end="")# 判断输赢_判断该单词是不是答案def whether_right_word():global letter, winif letter == word:win = Trueprint(f'恭喜你猜对了!!!该单词是\"{letter}\"。')else:print(f'很遗憾,该单词不是\"{letter}\"。')# 根据玩了几次,计算还有几次机会def count_chance():# m记录还有几次机会global m#print("\n")if m == 0:print('你的机会用完了')elif m <= 3:print(f'你只剩最后{m}次机会了,加油哦!')else:print(f"你还有{m}次机会,加油哦!")print("------------------------")words_all = ['ability', 'able', 'about', 'above', 'abroad', 'accept', 'accident', 'accurate', 'ache', 'achieve', 'across', 'act', 'active', 'activity', 'actor', 'actress', 'actually', 'add', 'addition', 'address', 'adult', 'advantage', 'adventure', 'advertisement', 'advice', 'advise', 'affect', 'afford', 'afraid', 'africa', 'after', 'afternoon', 'again', 'against', 'age', 'aged', 'ago', 'agree', 'ahead', 'aim', 'air', 'airline', 'airport', 'alarm', 'alive', 'all', 'allow', 'almost', 'alone', 'along', 'already', 'also', 'although', 'altogether', 'always', 'amazing', 'ambition', 'america', 'among', 'amount', 'amusement', 'amusing', 'ancient', 'and', 'angrily', 'angry', 'animal', 'another', 'answer', 'any', 'anybody', 'anyone', 'anything', 'anywhere', 'apologize', 'appear', 'apple', 'apply', 'april', 'area', 'argue', 'arm', 'army', 'around', 'arrange', 'arrival', 'arrive', 'art', 'article', 'artist', 'as', 'asia', 'ask', 'assistant', 'at', 'attack', 'attend', 'attention', 'attitude', 'attract', 'attractive', 'audience', 'august', 'aunt', 'australia', 'automatic', 'autumn', 'available', 'average', 'avoid', 'award', 'away', 'awful', 'baby', 'back', 'background', 'bad', 'bag', 'bakery', 'balance', 'ball', 'balloon', 'banana', 'bank', 'bar', 'base', 'basic', 'basket', 'basketball', 'bath', 'bathroom', 'battery', 'battle', 'be', 'beach', 'bear', 'beat', 'beautiful', 'beautifully', 'beauty', 'because', 'become', 'bed', 'bedroom', 'beef', 'before', 'beg', 'begin', 'beginning', 'behavior', 'behind', 'being', 'believe', 'bell', 'belong', 'below', 'belt', 'beside', 'besides', 'best', 'better', 'between', 'bicycle', 'big', 'bike', 'bill', 'bin', 'biology', 'bird', 'birthday', 'biscuit', 'bit', 'bite', 'black', 'blackboard', 'blanket', 'blind', 'block', 'blood', 'blow', 'blue', 'board', 'boat', 'body', 'boil', 'book', 'bored', 'boring', 'born', 'borrow', 'boss', 'both', 'bottle', 'bottom', 'bowl', 'box', 'boy', 'brain', 'brave', 'bread', 'break', 'breakfast', 'breath', 'breathe', 'bridge', 'bright', 'bring', 'britain', 'broadcast', 'brother', 'brown', 'brush', 'build', 'building', 'bund', 'burn', 'bus', 'business', 'businessman', 'busy', 'but', 'butter', 'butterfly', 'button', 'buy', 'by', 'bye', 'cabbage', 'cake', 'call', 'calm', 'camera', 'camp', 'can', 'canada', 'cancel', 'capital', 'captain', 'car', 'card', 'care', 'careful', 'carefully', 'careless', 'carrot', 'carry', 'cartoon', 'case', 'cat', 'catch', 'cause', 'cave', 'celebrate', 'cent', 'centre', 'century', 'certainly', 'chain', 'chair', 'challenge', 'chance', 'change', 'changeable', 'channel', 'character', 'charge', 'charity', 'chat', 'cheap', 'check', 'cheer', 'cheese', 'chemical', 'chemistry', 'chess', 'chicken', 'chief', 'child', 'childhood', 'china', 'chinese', 'chocolate', 'choice', 'choose', 'chopstick', 'christmas', 'church', 'cinema', 'circle', 'citizen', 'city', 'class', 'classmate', 'classroom', 'clean', 'clear', 'clearly', 'clerk', 'clever', 'click', 'climb', 'clinic', 'clock', 'close', 'clothes', 'cloud', 'cloudy', 'club', 'coat', 'coffee', 'coin', 'cold', 'collect', 'collection', 'college', 'colour', 'come', 'comfortable', 'common', 'communicate', 'community', 'company', 'compare', 'competition', 'complain', 'complete', 'completely', 'computer', 'concert', 'conclusion', 'conference', 'confidence', 'confident', 'confuse', 'congratulation', 'connect', 'consider', 'consist', 'contact', 'contest', 'continue', 'control', 'convenient', 'conversation', 'cook', 'cool', 'copy', 'corner', 'correct', 'correctly', 'cost', 'cotton', 'cough', 'count', 'country', 'couple', 'course', 'cousin', 'cover', 'crazy', 'cream', 'create', 'creative', 'cross', 'crowd', 'crowded', 'cry', 'culture', 'cup', 'custom', 'customer', 'cut', 'cute', 'cycle', 'dad', 'daily', 'damage', 'dance', 'dancer', 'danger', 'dangerous', 'dare', 'dark', 'date', 'daughter', 'day', 'dead', 'deal', 'dear', 'death', 'debate', 'december', 'decide', 'decision', 'decorate', 'deep', 'degree', 'delay', 'delicious', 'deliver', 'dentist', 'deny', 'departure', 'depend', 'describe', 'deserve', 'design', 'desire', 'desk', 'destroy', 'detail', 'detective', 'develop', 'development', 'dial', 'dialogue', 'diary', 'dictionary', 'die', 'diet', 'difference', 'different', 'difficult', 'difficulty', 'dig', 'dinner', 'direction', 'directly', 'director', 'dirty', 'disabled', 'disadvantage', 'disappear', 'disappointed', 'disaster', 'discover', 'discuss', 'discussion', 'dish', 'dishonest', 'dislike', 'distance', 'disturb', 'divide', 'do', 'doctor', 'does', 'dog', 'dollar', 'door', 'double', 'down', 'download', 'downstairs', 'draw', 'dream', 'drink', 'drive', 'driver', 'drop', 'dry', 'duck', 'dull', 'during', 'duty', 'each', 'eager', 'ear', 'early', 'earth', 'earthquake', 'easily', 'east', 'easy', 'eat', 'economy', 'education', 'educational', 'effect', 'effective', 'effort', 'egg', 'either', 'elder', 'electric', 'electricity', 'elementary', 'elephant', 'else', 'embarrassed', 'empty', 'enable', 'encourage', 'end', 'enemy', 'energy', 'engine', 'engineer', 'england', 'enjoy', 'enjoyable', 'enough', 'enrich', 'enter', 'entertainment', 'entrance', 'envelope', 'environment', 'equal', 'escape', 'especially', 'europe', 'eve', 'even', 'evening', 'event', 'ever', 'every', 'everybody', 'everyday', 'everyone', 'everyone', 'everything', 'everywhere', 'exactly', 'exam', 'examination', 'examination', 'examine', 'example', 'excellent', 'except', 'exchange', 'excited', 'exciting', 'excuse', 'exercise', 'exhibition', 'exist', 'exit', 'expect', 'expensive', 'experience', 'experiment', 'explain', 'explore', 'express', 'extra', 'eye', 'fable', 'face', 'fact', 'factory', 'fail', 'fair', 'fall', 'familiar', 'family', 'famous', 'fan', 'far', 'fare', 'farm', 'farmer', 'fashion', 'fast', 'fasten', 'fat', 'father', 'favour', 'favourite', 'fear', 'february', 'feed', 'feel', 'female', 'fence', 'ferry', 'festival', 'fever', 'few', 'field', 'fight', 'figure', 'fill', 'film', 'final', 'finally', 'find', 'fine', 'finger', 'finish', 'fire', 'firework', 'first', 'fish', 'fisherman', 'fit', 'fix', 'flag', 'flash', 'flat', 'flexible', 'flood', 'floor', 'flower', 'flu', 'fly', 'focus', 'follow', 'following', 'fond', 'food', 'fool', 'foolish', 'foot', 'football', 'for', 'forecast', 'foreign', 'foreigner', 'forest', 'forever', 'forget', 'forgetful', 'forgive', 'fork', 'form', 'forward', 'fountain', 'france', 'free', 'freedom', 'freeze', 'freezing', 'fresh', 'friday', 'fridge', 'fried', 'friend', 'friendly', 'friendship', 'frighten', 'frightened', 'frightening', 'from', 'front', 'frozen', 'fruit', 'fuel', 'full', 'fun', 'funny', 'furniture', 'further', 'future', 'gain', 'game', 'garden', 'gas', 'gate', 'general', 'generation', 'generous', 'gentle', 'gentleman', 'gently', 'geography', 'germany', 'get', 'gift', 'girl', 'give', 'glad', 'glass', 'go', 'goal', 'gold', 'golden', 'good', 'government', 'grade', 'graduate', 'grandfather', 'grandma', 'grandmother', 'grandpa', 'grape', 'grass', 'great', 'green', 'greenhouse', 'greet', 'ground', 'group', 'grow', 'guess', 'guest', 'guide', 'guitar', 'gun', 'habit', 'hair', 'half', 'hall', 'hamburger', 'hand', 'hang', 'happen', 'happily', 'happiness', 'happy', 'hard', 'hardly', 'hardworking', 'harm', 'harmful', 'hat', 'hate', 'have', 'head', 'headache', 'headline', 'headmaster', 'health', 'healthy', 'hear', 'heart', 'heat', 'heavily', 'heavy', 'height', 'hello', 'help', 'helpful', 'helpless', 'here', 'hero', 'hesitate', 'hide', 'high', 'hill', 'historical', 'history', 'hit', 'hobby', 'hold', 'hole', 'holiday', 'home', 'homeless', 'hometown', 'homework', 'honest', 'honesty', 'honey', 'honour', 'hope', 'hopeful', 'horrible', 'horse', 'hospital', 'host', 'hot', 'hotel', 'hour', 'house', 'housework', 'how', 'however', 'hug', 'huge', 'human', 'humorous', 'hungry', 'hunt', 'hurry', 'hurt', 'husband', 'ice', 'idea', 'if', 'ill', 'illness', 'imagine', 'immediately', 'importance', 'important', 'impossible', 'impression', 'improve', 'in', 'inch', 'include', 'including', 'income', 'increase', 'independent', 'indoor', 'industry', 'influence', 'information', 'ink', 'inside', 'instead', 'instruction', 'int', 'interest', 'interested', 'interesting', 'international', 'internet', 'interview', 'into', 'introduce', 'invent', 'invention', 'inventor', 'investigate', 'invitation', 'invite', 'iron', 'island', 'italy', 'item', 'jacket', 'jam', 'january', 'japan', 'jeans', 'job', 'join', 'joke', 'journalist', 'journey', 'joy', 'judge', 'juice', 'july', 'jump', 'june', 'junior', 'just', 'keen', 'keep', 'keyboard', 'kick', 'kid', 'kill', 'kilogram', 'kilometre', 'kind', 'kindergarten', 'kindness', 'king', 'kitchen', 'kite', 'knife', 'knock', 'know', 'knowledge', 'lab', 'lady', 'lake', 'lamp', 'land', 'language', 'lantern', 'large', 'last', 'late', 'later', 'laugh', 'law', 'lawyer', 'lay', 'lazy', 'lead', 'learn', 'leave', 'lecture', 'left', 'leg', 'lend', 'length', 'lesson', 'let', 'letter', 'level', 'librarian', 'library', 'lie', 'life', 'lift', 'light', 'like', 'likely', 'limit', 'limited', 'line', 'link', 'lion', 'liquid', 'list', 'listen', 'litter', 'little', 'live', 'local', 'locate', 'location', 'lock', 'london', 'lonely', 'long', 'look', 'lose', 'lost', 'lot', 'loud', 'loudly', 'love', 'lovely', 'low', 'luck', 'luckily', 'lucky', 'luggage', 'lunch', 'machine', 'mad', 'magazine', 'magic', 'mail', 'main', 'mainly', 'major', 'make', 'male', 'man', 'manage', 'manager', 'manner', 'many', 'map', 'march', 'mark', 'market', 'marry', 'match', 'material', 'maths', 'matter', 'may', 'may', 'maybe', 'meal', 'mean', 'meaning', 'meat', 'medical', 'medicine', 'medium', 'meet', 'meeting', 'member', 'memory', 'mention', 'menu', 'mess', 'message', 'metal', 'method', 'metre', 'middle', 'mile', 'milk', 'mind', 'minus', 'minute', 'mirror', 'miss', 'mistake', 'mix', 'mixture', 'model', 'modern', 'moment', 'monday', 'money', 'monitor', 'monkey', 'month', 'mood', 'moon', 'more', 'morning', 'most', 'mother', 'motorcycle', 'mountain', 'mouse', 'mouth', 'move', 'movie', 'mr', 'mrs', 'much', 'much', 'mum', 'museum', 'mushroom', 'music', 'must', 'name', 'narrow', 'nation', 'national', 'nationality', 'native', 'natural', 'nature', 'naughty', 'near', 'nearby', 'nearly', 'necessary', 'need', 'neighbour', 'neighbourhood', 'neither', 'nervous', 'net', 'network', 'never', 'new', 'news', 'newspaper', 'next', 'nice', 'night', 'nobody', 'noise', 'noisy', 'none', 'noodle', 'nor', 'north', 'nose', 'note', 'nothing', 'notice', 'novel', 'november', 'now', 'nowadays', 'nowhere', 'number', 'nurse', 'obey', 'observe', 'occupation', 'ocean', 'october', 'of', 'off', 'offer', 'office', 'officer', 'official', 'often', 'oil', 'old', 'olympic', 'on', 'once', 'one', 'online', 'only', 'onto', 'open', 'operate', 'operation', 'opinion', 'opposite', 'or', 'orange', 'order', 'ordinary', 'organization', 'organize', 'other', 'ought', 'out', 'outdoor', 'outing', 'outside', 'oven', 'over', 'own', 'owner', 'pacific', 'pack', 'page', 'pain', 'paint', 'painting', 'pair', 'palace', 'pale', 'panda', 'paper', 'parent', 'paris', 'park', 'part', 'partner', 'party', 'pass', 'passage', 'passenger', 'passport', 'past', 'patient', 'pay', 'peace', 'pear', 'pearl', 'pen', 'pencil', 'people', 'per', 'percent', 'perfect', 'performance', 'perhaps', 'person', 'personal', 'pet', 'phone', 'photo', 'photograph', 'physical', 'physics', 'piano', 'pick', 'picnic', 'picture', 'piece', 'pig', 'pill', 'pilot', 'pin', 'pineapple', 'pink', 'pioneer', 'pity', 'pizza', 'place', 'plan', 'plane', 'planet', 'plant', 'plastic', 'plate', 'platform', 'play', 'player', 'playground', 'pleasant', 'please', 'pleased', 'pleasure', 'plenty', 'plus', 'pocket', 'poem', 'point', 'pole', 'policeman', 'politely', 'politics', 'pollute', 'pollution', 'pool', 'poor', 'popular', 'population', 'pork', 'possible', 'possibly', 'post', 'postcard', 'poster', 'postman', 'pot', 'potato', 'pound', 'power', 'powerful', 'practice', 'praise', 'precious', 'predict', 'prefer', 'prepare', 'present', 'president', 'press', 'pretend', 'pretty', 'prevent', 'price', 'primary', 'print', 'prison', 'private', 'prize', 'probable', 'probably', 'problem', 'process', 'produce', 'product', 'professional', 'programme', 'progress', 'project', 'promise', 'pronounce', 'properly', 'protect', 'proud', 'prove', 'proverb', 'provide', 'public', 'publish', 'pull', 'purpose', 'push', 'put', 'quality', 'quarter', 'queen', 'question', 'quick', 'quickly', 'quiet', 'quietly', 'quite', 'quiz', 'race', 'radio', 'railway', 'rain', 'rainy', 'raise', 'rarely', 'rather', 'reach', 'read', 'ready', 'real', 'realize', 'really', 'reason', 'rebuild', 'receive', 'recent', 'recently', 'recognize', 'record', 'recycle', 'red', 'reduce', 'reference', 'refuse', 'regular', 'relationship', 'relative', 'relax', 'release', 'rely', 'remember', 'remind', 'repair', 'repeat', 'reply', 'report', 'reporter', 'republic', 'require', 'research', 'resource', 'respect', 'response', 'responsibility', 'responsible', 'rest', 'restaurant', 'result', 'retired', 'return', 'reuse', 'review', 'reward', 'rice', 'rich', 'rid', 'ride', 'right', 'ring', 'rise', 'river', 'road', 'roast', 'robot', 'rock', 'rocket', 'role', 'room', 'root', 'rope', 'rose', 'rough', 'round', 'row', 'rubbish', 'rude', 'rule', 'run', 'rush', 'sad', 'sadly', 'safe', 'safely', 'safety', 'salad', 'salary', 'sale', 'salt', 'salty', 'same', 'sandwich', 'satisfied', 'satisfying', 'saturday', 'sauce', 'save', 'say', 'saying', 'schedule', 'school', 'science', 'scientist', 'score', 'screen', 'sea', 'seafood', 'search', 'seaside', 'season', 'seat', 'second', 'secondary', 'secret', 'secretary', 'section', 'see', 'seed', 'seem', 'seldom', 'select', 'sell', 'send', 'senior', 'sense', 'sentence', 'september', 'serious', 'seriously', 'serve', 'service', 'set', 'settle', 'several', 'shake', 'shall', 'shame', 'shape', 'share', 'sheep', 'shelf', 'shine', 'ship', 'shirt', 'shoe', 'shop', 'short', 'should', 'shout', 'show', 'shower', 'shut', 'shy', 'sick', 'side', 'sight', 'sightseeing', 'sign', 'signal', 'silent', 'silk', 'silly', 'similar', 'simple', 'since', 'sing', 'singer', 'single', 'sir', 'sister', 'sit', 'situation', 'size', 'skate', 'skill', 'skin', 'skirt', 'sky', 'sleep', 'slow', 'slowly', 'small', 'smart', 'smell', 'smile', 'smoke', 'snack', 'snow', 'snowy', 'so', 'social', 'society', 'soft', 'softly', 'soldier', 'solution', 'solve', 'some', 'somebody', 'someone', 'something', 'sometimes', 'son', 'song', 'soon', 'sorry', 'sound', 'soup', 'south', 'space', 'spaceship', 'spare', 'speak', 'special', 'speech', 'speed', 'spend', 'spoon', 'sport', 'spread', 'square', 'staff', 'stamp', 'stand', 'star', 'start', 'state', 'station', 'stay', 'steak', 'steal', 'steam', 'step', 'stick', 'still', 'stocking', 'stomachache', 'stone', 'stop', 'store', 'storm', 'story', 'straight', 'strange', 'strawberry', 'street', 'stress', 'strict', 'strike', 'stuck', 'student', 'study', 'stupid', 'style', 'subject', 'succeed', 'success', 'successful', 'such', 'suddenly', 'suffer', 'sugar', 'suggest', 'suggestion', 'summer', 'sun', 'sunday', 'sunny', 'super', 'supermarket', 'supper', 'support', 'suppose', 'sure', 'surface', 'surprise', 'surprised', 'survey', 'survive', 'sweep', 'sweet', 'swim', 'symbol', 'system', 'table', 'take', 'talent', 'talk', 'tall', 'tap', 'tape', 'task', 'taste', 'taxi', 'tea', 'teach', 'teacher', 'team', 'tear', 'technology', 'teenager', 'telephone', 'telephone', 'television', 'tell', 'temperature', 'temple', 'tennis', 'term', 'terrible', 'test', 'text', 'than', 'thank', 'thankful', 'that', 'theatre', 'then', 'these', 'thick', 'thin', 'thing', 'think', 'thirsty', 'this', 'those', 'though', 'thought', 'through', 'throughout', 'throw', 'thursday', 'ticket', 'tidy', 'tie', 'tiger', 'till', 'time', 'tip', 'tired', 'title', 'to', 'together', 'tomato', 'tomorrow', 'tonight', 'too', 'tool', 'tooth', 'toothache', 'top', 'topic', 'touch', 'tour', 'tourist', 'toward', 'tower', 'town', 'toy', 'tradition', 'traditional', 'traffic', 'train', 'translate', 'transport', 'transportation', 'travel', 'tree', 'trick', 'trip', 'trouble', 'trousers', 'truck', 'true', 'trust', 'truth', 'try', 'tuesday', 'turkey', 'turn', 'twice', 'twin', 'type', 'umbrella', 'uncle', 'under', 'underground', 'underlined', 'understand', 'unfortunately', 'unhappy', 'unhealthy', 'uniform', 'unit', 'united', 'university', 'unless', 'until', 'unusual', 'up', 'upset', 'upstairs', 'use', 'useful', 'useless', 'usual', 'usually', 'value', 'variety', 'various', 'vegetable', 'very', 'victory', 'video', 'view', 'village', 'violin', 'visit', 'visitor', 'vocabulary', 'voice', 'volleyball', 'volunteer', 'wait', 'waiter', 'waitress', 'wake', 'walk', 'wall', 'want', 'war', 'warm', 'warn', 'wash', 'waste', 'watch', 'water', 'wave', 'way', 'weak', 'wealth', 'wear', 'weather', 'web', 'website', 'wednesday', 'week', 'weekday', 'weekend', 'weigh', 'weight', 'welcome', 'well', 'west', 'western', 'wet', 'what', 'when', 'where', 'whether', 'which', 'while', 'white', 'who', 'whole', 'whom', 'whose', 'why', 'wide', 'widely', 'widen', 'wife', 'wild', 'will', 'win', 'wind', 'window', 'windy', 'wine', 'wing', 'winner', 'winter', 'wisdom', 'wise', 'wish', 'with', 'within', 'without', 'wolf', 'woman', 'wonder', 'wonderful', 'wood', 'wooden', 'word', 'work', 'worker', 'world', 'worry', 'worth', 'would', 'wound', 'wounded', 'write', 'writer', 'wrong', 'year', 'yellow', 'yesterday', 'yet', 'yogurt', 'young', 'zero', 'zoo']'''# 以下变量待询问letter= 'a' # 猜的字母是什么word = 'word' # 答案是什么,从列表中随机的时候赋值的list = [] # 在哪个列表中随机答案times = 1# 猜的字母在单词中有几个index+1 = 1# 猜的字母在单词中的位置chances = 1# 共有几次机会n = 1# 记录这是第几次猜m = 1# 记录还有几次机会length = 3 #记录单词的长度word_whileguess = 'a---'# 显示正在猜的单词部分clues = []# 显示所有已知的提示'''win = False# 建立一个变量判断是否成功word, first = get_index(words_all)# 先把答案随机好length = len(word)clues = []# 显示所有已知的提示# beginningprint("""这是一个倒吊人小游戏。游戏规则如下:1.已知一个英语单词, 请你猜一猜这个词是什么2.我会告诉你这个单词由几个字母组成3.你可以有几次机会可以猜, 每次可以猜组成这个单词的字母, 也可以直接猜单词4.如果你不想猜了, 可以输入0结束游戏""")a = input("""你有两种模式可以选:输入1进入双人模式, 你可以请你的朋友输入单词输入0进入单人模式, 会为你在中考词汇中随机一个单词""")if a == '1':word = input("请输入一个英语单词:")else:print("已为你在中考考纲词汇中随机了一个单词\n")# print(word)print(f"这个单词有{len(word)}个字母")word_whileguess = first+(length-1)*"-"print(f"首字母为\"{first}\"")print(word_whileguess)chances = input(f'请问你需要几次机会?(默认为{len(word)*2}次)\n')if chances:# 输入的不是空chances = float(chances)# 先转成小数(防止输入的是小数导致报错)while chances <= 0:# 次数不能为负print("次数不能为负")print("请输入一个正整数!")chances = float(input(f'请问你需要几次机会?(默认为{len(word) * 2}次)\n'))chances = round(chances)# 四舍六入五成双, 听说这个机制更好, 反正改起来太麻烦了就这样用吧(else:chances = len(word)*2# 启用默认次数print("------------------------")print("开始游戏!\n\n")print(f"这个单词有{len(word)}个字母")print(f"你一共有{chances}次机会")print("每次机会,你可以输入一个字母或直接猜测单词")print("输入0可以结束游戏")print("------------------------")m = chances# 第几次机会n = 0# 第几次猜while m > 0 :m -= 1#机会-1n += 1#次数+1print(f"这是第{n}次机会")letter = input('开始猜测:') # 只能输入一个字母或直接猜测单词print("\n\n")if letter=='0' or not letter:m += 1n -= 1# 放弃了的话机会和次数就不扣了breakif len(letter) != 1:# 判断字母是否为该单词whether_right_word()else:# 判断字母是否在单词中+判断字母在单词中的哪个位置whether_in()print(word_whileguess)print(f"这个单词里面没有这些字母:{clues}")if win:break# 计算还有几次机会count_chance() # m记录还有几次机会print("------------------------")print("游戏结束")if win:print(f"你只用了{n}次机会就猜对了")else:print(f"正确答案是{word}哦!")print(f"你用了{n}次机会,没有猜对")

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。