Login Register


100 Program Challenge..For everyone filter_list
Author
Message
RE: 100 Program Challenge..For everyone #8
(05-13-2016, 11:16 PM)Oni Wrote: I'll try and do Hangman. Biggrin

Spoiler: python version
Code:
from random import randint from os import system def cls(): if __import__('os').name=="nt": system('cls') else: system('clear') words=["animal","vast","brilliant","exit","passenger","binding","loyal","cold","generation","cruise","abstract","raspberry","prime","red","episode","forgotten","dust","virgin","alien","focus","tactic","cut","pink","skin","goggles","crawling","heart"] word=list(words[randint(0,len(words)-1)]) disp=['_']*len(word) left=12 guessed=[] while left>=0: cls() print("Guesses left:\t "+str(left)+"\nAlready guessed:",', '.join(guessed),"\nProgress:\t",' '.join(disp),"\n\n") guess=input("Guess a letter: ") while guess in guessed or len(guess)>1: guess=input("Invalid option. Choose another letter: ") guessed.append(guess) if word.count(guess)>0: for i in range(len(word)): if word[i]==guess: disp[i]=guess if disp==word: print("\nYou Win! The word is "+''.join(word)) exit() else: left-=1 print("Out of guesses, you lose. The word was "+''.join(word))
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

[+] 1 user Likes Inori's post
Reply





Messages In This Thread
RE: 100 Program Challenge..For everyone - by Oni - 05-13-2016, 11:16 PM
RE: 100 Program Challenge..For everyone - by Inori - 05-13-2016, 11:28 PM
RE: 100 Program Challenge..For everyone - by Rick - 06-04-2016, 03:39 PM



Users browsing this thread: