-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathPython Guessing Game.py
More file actions
33 lines (27 loc) · 916 Bytes
/
Python Guessing Game.py
File metadata and controls
33 lines (27 loc) · 916 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
#Basic Guessing Game Using Python
#Developer - Dernyt-TPE
import random
pcRand=random.randint(0, 1000)
index=int()
def prompt(wrongGuess):
global index
if wrongGuess > pcRand:
if index==0:print("Oops! Again Guess is incorrect")
index = 0
nextGuess=int(input("Guess a number less than "+ str(wrongGuess) +"\n"))
prompt(nextGuess)
elif wrongGuess < pcRand:
if index == 0: print("Oops! Again Guess is incorrect")
index = 0
nextGuess = int(input("Guess a number more than " + str(wrongGuess)+ "\n"))
prompt(nextGuess)
elif wrongGuess == pcRand:
print("Congratulations! Your Guess is correct - You Won")
#prompting user for guess no.
guess=int(input("Guess a number\n"))
if (guess==pcRand):
print("Congratulations! Your Guess is correct - You Won")
else:
print("Oops! Guess is incorrect")
index=1
prompt(guess)