Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'output': 0.04; 'try:': 0.07; 'subject:How': 0.09; 'err:': 0.09; 'subject:would': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'itself.': 0.11; '"no":': 0.16; '"yes":': 0.16; 'benjamin': 0.16; 'cc:name:python list': 0.16; 'guessing': 0.16; 'wrote:': 0.17; 'import': 0.21; 'cc:2**0': 0.23; 'random': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; '(which': 0.26; 'guess': 0.27; 'question': 0.27; 'this?': 0.28; 'run': 0.28; 'thursday,': 0.30; 'sense': 0.31; 'print': 0.32; 'code:': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'except': 0.36; 'explain': 0.36; 'but': 0.36; 'subject:: ': 0.38; 'your': 0.60; 'between': 0.63; 'more': 0.63; 'show': 0.63; 'subject:this': 0.84; '2013': 0.84; 'oscar': 0.84; 'played': 0.84; 'subject:you': 0.88; 'eli': 0.93 X-Received: by 10.49.12.97 with SMTP id x1mr26051qeb.25.1360887592086; Thu, 14 Feb 2013 16:19:52 -0800 (PST) Newsgroups: comp.lang.python Date: Thu, 14 Feb 2013 16:19:51 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=75.62.141.92; posting-account=T0Q4ngoAAADFqe_JPINLNp5NgW2XDzan References: <58be0de9-e39e-4b95-99da-d8eb3270db33@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 75.62.141.92 MIME-Version: 1.0 Subject: Re: How would you do this? From: eli m To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360890057 news.xs4all.nl 6942 [2001:888:2000:d::a6]:45956 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38897 On Thursday, February 14, 2013 4:09:37 PM UTC-8, Oscar Benjamin wrote: > On 14 February 2013 23:34, eli m wrote: > > > I want to make a guess the number game (Which i have), but i want to make the computer play the game against itself. How would i do this? > > > > Your question would make more sense if you would show your program and > > also explain how you would like the output to look when the computer > > played itself. > > > > > > Oscar This is my code: #Guess the number game import random run = 0 while run == 0: print ("I am thinking of a number between 1 and 100") num = random.randint(1, 100) num = int(num) guesses = 0 guessestaken = 0 while guesses == 0: try: guess = raw_input("Your guess:") guess = int(guess) guessestaken = (guessestaken) + 1 guessestaken = int(guessestaken) if guess == (num): print 'Correct! It took you', int(guessestaken), 'guesses!' playagain = raw_input("Do you want to play again?") if playagain == "yes": guesses = 1 if playagain == "no": run = 1 if guess > num: print ("My number is lower") if guess < num: print ("My number is higher") except TypeError, err: print ("Not a valid number") I would like it to show the computer guessing the numbers.