Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99177

Re: error help import random

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: error help import random
Date Fri, 20 Nov 2015 11:10:49 -0700
Lines 15
Message-ID <mailman.14.1448043092.2291.python-list@python.org> (permalink)
References <8b0ec311-ab7f-429d-877f-d205ad6008d9@googlegroups.com> <n2nmup$j2n$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de SzReWtgcy9+/bV/JPUMHZgry5ostuS1f5aYiW7zZijUg==
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.056
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:help': 0.07; 'python': 0.10; 'subject:error': 0.11; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:import': 0.16; 'subject:random': 0.16; 'wrote:': 0.16; 'integer': 0.18; '2015': 0.20; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'code': 0.30; 'run': 0.33; 'received:google.com': 0.35; 'nov': 0.35; 'but': 0.36; 'instead': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'total': 0.62; 'here.': 0.62; 'between': 0.65; '20,': 0.66; 'fortune': 0.66; 'inclusive': 0.84; 'otten': 0.84; 'riley': 0.84; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=QYlXWSJui0v3ugQtDqW3oX31Mdgdvqp0Gas/8WOTRns=; b=szygZeLrNNf3osH9GMQyKlHdmiV/VWgokPC3u72jm2WESTGvcdfQQ1hn8StMvP1ZLu cqs4b+hyHjmSsoA1ECLnSAJpveDrH4y/hYR2CFk0TJ7wNTAPen64keWEsBYyMlDakUJq NdXPOu1c79zf+PcOxbC6y+CiUs4kV24aFDM8K+Cq2Mj/DfkQJTgBOqGhCrB6ETlaF7LV bwbhYLiuZdfqrSmca+0tWfF0hufoz9SsNUJ8SlSWR93q8YfDUm1JSB3CnkUEzyidXA6R qISa6fexQXYFYkZRnk/3R8P0FuBm4iYlJmBh+SBmrnWRUhgpNTfPVPO68iDgfL7LDGMk ZgVA==
X-Received by 10.107.137.226 with SMTP id t95mr14832015ioi.188.1448043088922; Fri, 20 Nov 2015 10:11:28 -0800 (PST)
In-Reply-To <n2nmup$j2n$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99177

Show key headers only | View raw


On Fri, Nov 20, 2015 at 10:57 AM, Peter Otten <__peter__@web.de> wrote:
> Dylan Riley wrote:
>
>> input("\nPress enter to see your fortune")
>
> Make sure that you run your code with Python 3, not Python 2.

Or if you must use Python 2, use raw_input() instead of input().

>> fortune = random.randrange(6) + 1

Also, you have an off-by-one error here. randrange(6) will give you an
integer between 0 and 5, inclusive (a total of 6 possible values).
Adding 1 will then result in an integer between 1 and 6, inclusive,
but you don't have a case for a value of 6.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

error help import random Dylan Riley <dylan.riley@hotmail.com> - 2015-11-20 09:22 -0800
  Re: error help import random Chris Angelico <rosuav@gmail.com> - 2015-11-21 04:30 +1100
  Re: error help import random Peter Otten <__peter__@web.de> - 2015-11-20 18:57 +0100
  Re: error help import random Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-20 11:10 -0700
  Re: error help import random Terry Reedy <tjreedy@udel.edu> - 2015-11-20 15:15 -0500
    Re: error help import random Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-11-20 23:03 +0000
      Re: error help import random Dylan Riley <dylan.riley@hotmail.com> - 2015-11-20 19:26 -0800
  Re: error help import random Seymore4Head <Seymore4Head@Hotmail.invalid> - 2015-11-20 18:05 -0500

csiph-web