Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Rules of the Game | Game Word
Beginner Final Project: Hangman

book
Rules of the Game

Rules of the Hangman

Function plan and its connection

Final playable game version

After finishing writing the code we will be able to test our game using the file with words. During the course to test functions, we will have small words lists.

Let's prepare to the Hangman!

First, we need to import libraries needed for work and set new function. This function, which is named load_words() is used to get all words from one given file. During the project, we will name this file word_list.

Use hints if needed!

Завдання

Swipe to start coding

  1. Import the random library.
  2. Import the string library.
  3. Set new function load_words that will load words from the file.
  4. Set word_list file variable that includes words for the game.
  5. Return word_list variable.

Рішення

# Import the random library
import random
# Import the string library
import string

# Set the load_words() function
def load_words():
# Set the word_list variable
word_list = open('words.txt', 'r').readline().split()
# Return the word_list
return word_list

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1
single

single

# Import the random library
___
# Import the string library
___

# Set the load_words function
___:
# Set the word_list variable
___ = open('words.txt', 'r').readline().split()
# Return the word_list
___

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

We use cookies to make your experience better!
some-alt