Fandom

Python Wiki

Number guessing game

43pages on
this wiki
Add New Page
Talk0 Share

A simple number guessing game written in Python.

 import random
 f = 0
 num = random.randint(1, 100)
 print "I'm thinking of an number between 1 and 100. Guess it!"
 while f == 0:
     # Convert to "input" from "raw_input" to work with 3.x
     theGuess = int(raw_input("Your guess: "))
     if theGuess == num:
          print "Great Job!"
          f = 1
     else:
          print "Try Again."

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.