-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuessingGame.py
More file actions
40 lines (29 loc) · 792 Bytes
/
Copy pathGuessingGame.py
File metadata and controls
40 lines (29 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
=============================My Logic==============================
secret_word = "giraffe"
guess = ""
attempt = 0
while guess != secret_word and attempt != 3:
guess = input("Enter your Guess : ")
attempt += 1
if attempt == 3:
print("You are out of attempts! You did not win.")
else:
print("You win!")
====================================================================
"""
secret_word = "giraffe"
guess = ""
guess_count = 0
guess_limit = 3
out_of_guesses = False
while guess != secret_word and not(out_of_guesses):
if guess_count < guess_limit:
guess = input("Enter your guess : ")
guess_count += 1
else:
out_of_guesses = True
if out_of_guesses:
print("Sorry you are out of guesses. You lose!")
else:
print("You win!")