Skip to content

Commit 026379d

Browse files
authored
Add number guessing exercise solution
1 parent 9d61225 commit 026379d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ch08-conditional-logic/3-control-the-flow-of-your-program.py

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Solutions to review exercises
33

44

5+
# --- Exercise 1
56
# Display whether the length of user input is <, > or = 5 characters
67

78
my_input = input("Type something: ")
@@ -12,3 +13,15 @@
1213
print("Your input is greater than 5 characters long.")
1314
else:
1415
print("Your input is 5 characters long.")
16+
17+
18+
# --- Exercise 2
19+
# Number guessing program ("guess" the number 3)
20+
21+
print("I'm thinking of a number between 1 and 10. Guess which one.")
22+
my_guess = input("Type in your guess: ")
23+
24+
if my_guess == "3":
25+
print("You win!")
26+
else:
27+
print("You lose.")

0 commit comments

Comments
 (0)