Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by Akshat ( 13 years ago )
import random
words = ['string', 'car', 'lisp', 'python', 'cola', 'perl', 'php', 'guido']
for each in words: each = each.lower()
word_index = random.randint(0, len(words) - 1)
word = words[word_index]
attempts = 0
stars = list(len(word) * '*')
while attempts < 11:
print('\n\n{0}\nNumber of attempts made: {1}'.format(''.join(stars), attempts))
guess = input('Take a guess: ')
attempts += 1
for each in word:
if guess == each:
stars[word.find(guess)] = guess
if ''.join(stars) == word:
print('\nYes! The correct word is',''.join(stars))
print('You passed!')
attempts = 12
elif attempts >= 11 and guess not in word:
print('\nSorry, you faild.\nThe correct word was',word)
elif not guess or guess not in word:
print('Try again!')
Revise this Paste
Parent: 66084