import random
Number = random.randrange(100)+1
Tryz = 1
Attempt = int(raw_input("Please enter the number of attempt you want: "))
Guess = int(raw_input("Please guess the the number: "))
while Attempt != Tryz and Guess != Number:
Tryz += 1
if Guess < Number:
Guess = int(raw_input("Try a higher number: "))
else:
Guess = int(raw_input("Try a lower number: "))
if Tryz == Attempt:
print "You have ran out of tries the correct number is ", Number
else:
print "You have guessed it in ", Tryz, "tries"
print "The correct number was ", Number
Vusumuzi 0 Light Poster
Vusumuzi 0 Light Poster
woooee 814 Nearly a Posting Maven
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
fonzali 0 Light Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
fonzali 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.