Jan-15-2017, 06:07 PM
import time
import sys
# introduction to the game
print("You are playing the guessing game! To win you must guess the word, within the 5 lives you are given. If you use all 5 lives, you lose!")
time.sleep(2)
print("Type 'yes' when your ready to play")
time.sleep(0.5)
#behind the scenes stuff
word = 'dog'
lives = 5
win = 0
# game
ans = input("Ready: ")
while ans == 'yes':
user = input("Please guess a letter: ")
if user == word[1] or word[3] or word[2]:
print("Well done! You guessed a letter correctly!")
win = win + 1
time.sleep(1)
print("You have", lives, "lives!")
time.sleep(2)
if user != word[1] or word[3] or word[2]:
print("Wrong! You guessed incorrectly!")
time.sleep(1)
lives = lives - 1
print("You have", lives, "lives remaining!")
time.sleep(2)
#this is for if you lose or win
if win == 3:
print("You've won!")
time.sleep(0.5)
print("Want to play again?")
ans = input("Yes or no: ")
elif lives == 0:
print("You lose!")
time.sleep(0.5)
print("Want to play again?")
ans = input("Yes or no: ")
if ans == 'no':
sys.exit FOR SOME REASON THE INVALID SYNTAX IS COMING UP, I THINK THERE ARE OTHER SECTIONS OF THIS CODE INCORRECT, HOWEVER I JUST SIMPLY DON'T UNDERSTAND WHAT THE ERROR MESSAGE MEANS (INVALID SYNTAX - STRING INDEX OUT OF RANGE).
THANKS AND YES I AM NEW TO THE FORUM,
DARKREAPER1959
