0% found this document useful (0 votes)
6 views

Python Project Code

Uploaded by

Faizan Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python Project Code

Uploaded by

Faizan Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import random

name = input("What is your name? ")


print("Good Luck ! ", name)

words = ['rainbow', 'computer', 'science', 'programming',


'python', 'mathematics', 'player', 'condition',
'reverse', 'water', 'board', 'Faizan']

word = random.choice(words)
print("Guess the characters")
guesses = ''
turns = 12

while turns > 0:


failed = 0

for char in word:


if char in guesses:
print(char, end=" ")
else:
print("_", end=" ")
failed += 1

if failed == 0:
print("\nYou Win")
print("The word is: ", word)
break

print()
guess = input("guess a character:")
guesses += guess

if guess not in word:


turns -= 1
print("Wrong")
print("You have", + turns, 'more guesses')

if turns == 0:
print("You Lose")
print("The word was: ", word)

You might also like