python guess the word game

0. effect#

1. Code#

# Guess the word game
import random #Add to
WORDS =("python","juice","easy","difficult","answer","continue","phone","hello","pose","game")print("Welcome to the word guessing game\n Combine letters into a correct word")
iscontinue ="Y"while iscontinue=="Y" or iscontinue=="Y": #cycle
 # Pick a word randomly from the sequence
 word = random.choice(WORDS)
 # A variable that determines whether the player guessed correctly
 correct = word
 # Create out-of-order words
 jumble =""print(word)while word: #word is not an empty string
  # According to word length, generate random position of word
  position = random.randrange(len(word))
  # Combine position letters into out-of-order words
  jumble+=word[position]
  # By slicing, delete the position letter from the original word
  word = word[:position]+word[(position+1):]print("Words after disorder:",jumble)
 guess =input("\nPlease guess:")while guess != correct and guess !="":print("Sorry. Incorrect")
  guess =input("Keep guessing")if guess == correct:print("Awesome, you guessed it")
  iscontinue =input("\n whether to continue (Y/N):") #Whether to continue the game

Just learn that Python does not have a semicolon. Its indentation is to judge the logical continuous position. Pay attention to the indentation, otherwise an error will occur.

Recommended Posts

python guess the word game
Python implements word guessing game
Python realizes the guessing game
Python implements the brick-and-mortar game
Python simply implements the snake game
Python solves the Tower of Hanoi game
Python basic actual combat-guess the age game
2.1 The Python Interpreter (python interpreter)
Python implements the source code of the snake game
Python writes the game implementation of fishing master
Use python to realize the aircraft war game
Python implements tic-tac-toe game
Python implements tic-tac-toe game
Python, PyGame game project
Python implements Tetris game
Python implements minesweeper game
Python crawler-Yao word cloud
Consolidate the Python foundation (2)
Python implements guessing game
Realize the tank battle game with Python | Dry Post
Realize the tank battle game with Python | Dry Post
Consolidate the foundation of Python (4)
Python3 realizes airplane war game
Consolidate the foundation of Python(7)
Python implements WeChat airplane game
Consolidate the foundation of Python(6)
Python implements a guessing game
Ubuntu install the latest Python 3.
Python implements digital bomb game
Python realizes apple eating game
The difference between Python extensions
Python implements simple tic-tac-toe game
Consolidate the foundation of Python(5)
Consolidate the foundation of Python (3)
The usage of wheel in python
How Python implements the mail function
How does python change the environment
Python handles the 4 wheels of Chinese
Python3 implements the singleton design pattern
How to save the python program
Python simulation of the landlord deal
What is the use of Python
​What are the numbers in Python?
Python implements the steepest descent method
Python implements the actual banking system
Python implements digital bomb game program
Talking about the modules in Python
The premise of Python string pooling
Secrets of the new features of Python 3.8
How Python implements the timer function
How to view the python module
Python implements the aircraft war project
The father of Python joins Microsoft
The operation of python access hdfs
The usage of tuples in python
End the method of running python