repl.it
@mralam4769/

Python Y9 L3 Guess a number & If else

Python

No description

fork
loading
Files
  • main.py
main.py
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
import random 
answer = random.randint(1,100) 
#easy challenge 1 10
#meduium 1 to 50
#hard 1 to 100
#challeng= input("From the list below what guess a number game challenge do you choose?")
print("************* welcome to my guessing game ****")
print("**** Guess a number between 1 to 100    ***** ")
guess = int(input("Guess a number: "))
#wrap the number in integer because it is integer
# Alternative line code if using numbers:
# guess = int(input("Guess a number: "))



while guess != answer:
    print("That's wrong, try again!")
    guess = int(input("Guess a number: "))
    if guess > answer:
      print("Guess lower")
    else:
      print("Guess higher")
#wrap the number in integer because it is an integer


print("\nWell done, that's right!")

input("\nPress ENTER to exit program")