hangman's People
Forkers
maryammahfouzoo senaguvercinoglu deniztekkaya kingskadar paperpapillon lokmen200 cfourtalina hashimkhawaja jinkhan22 chseven ridhamgondaliya annbibik ahmedned182 amostimi maxcodextc z4avinash saptarshidas131 zarif93 vikashojaswin noeti tauhidalam acewealth alexamb12 dhrubobarman codecr4 kiran-sayi vijayrajay12 pranav625 mmcg91 rqd3v iamarjotsingh niravunt sagar-gath anvarnarz mick-r kathan511 rajnishgargcloudrepository verinope turbojapuraefac caristi92 timmykoo vignesh4u2 kevogaba pimlotb somsokleap wicklet13 cwd0204 970731 hemanthakrishna janaya425 ersohailjaved adnanshamim sirajnak klumar trakyalilter clalloures asdfsg-star tintinji gitdutt dineth456 buschti rylandgrounds krishnaasrinivas jaybeloved kailashgkg brinmazza karthikapril kaushikram25 ayobami-ctr nakso rapaidfireagent attit-maharjan thisismailson aldirahmanws moradohito kaushik701 ahmadsaad10 arpangoyal98 ouhilalmohamed logiqal dmin61 light771 macaylah chenzhiguang081 robin768 haard7 devblakee jns6eey rishadroxx vinayvelliboina jrucha funcode99 shwetakamreddi shveenita ahmedk-n willardnyamombe akshat1498 shahiabid saisuryastallone rellkohangman's Issues
How to integrate the progress visual in the main code?
keep being told the letter I chose was not in the word. Tried every letter.Why?
import random
from words import words
import string
def get_valid_word(words):
word = random.choice(words)
while '-' in word or ' ' in word:
word = random.choice(words)
return word
def hangman():
word = get_valid_word(words)
word_letters = set(word)
alphabet = set(string.ascii_uppercase)
used_letters = set()
lives = 1000
while len(word_letters) > 0 and lives > 0:
print('You have', lives, 'lives left and you have used these letters: ', ' '.join(used_letters))
word_list = [letter if letter in used_letters else '-' for letter in word]
print('Current word: ', ' '.join(word_list))
user_letter = input('Guess a letter: ').upper()
if user_letter in alphabet - used_letters:
used_letters.add(user_letter)
if user_letter in word_letters:
word_letters.remove(user_letter)
print('')
else:
lives = lives - 1
print('That letter is not in the word. Please try again.')
elif user_letter in used_letters:
print('You have already used that letter. Please try again.')
else:
print('Invalid character. Please try again.')
if lives == 0:
print('You died, sorry. The word was ', word)
else:
print('You have guess the word', word, '!')
while name == 'main':
hangman()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.