Code Monkey home page Code Monkey logo

hangman699's Introduction

Hangman

Hangman is a classic game in which a player thinks of a word and the other player tries to guess that word within a certain amount of attempts.

This is an implementation of the Hangman game, where the computer thinks of a word and the user tries to guess it.

Milestone_3

There are 2 functions:

  • ask_for_input() This prompts the user for a letter, and saves it to a variable called 'guess'
  • check_guess(guess) This checks whether the guess is in the word

Milestone_4

Created a 'Hangman' class, taking word_list (list of strings) and num_lives (int) as parameters, where num_lives takes a default value of 5.

The computer makes a random choice from the word_list and allocates it to the attibute 'word'.

Added the 'ask_for_input()' and 'check_guess()' methods to the class.

An attribute 'word_guessed' is initialised as a list of underscores ('_') of the same length as the 'word' attribute. Each time the user correctly guesses a letter, the corresponding underscore is replaced by the letter. If an incorrect guess is made, the num_lives is decremented.

Milestone_5

Put all the previous code milestones together to implement a working version of the game.

hangman699's People

Contributors

kevdocherty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.