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


Groups > comp.lang.python > #46861

Re: Beginner question

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string': 0.09; 'logic': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'though...': 0.09; 'trailing': 0.09; 'subject:question': 0.10; 'random': 0.14; '"some': 0.16; 'comma': 0.16; 'guessing': 0.16; 'parentheses:': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'substring': 0.16; 'tuple': 0.16; 'tuple,': 0.16; 'wrote:': 0.18; 'written,': 0.19; '>>>': 0.22; 'appears': 0.22; 'code,': 0.22; 'programming': 0.22; 'header :User-Agent:1': 0.23; 'fairly': 0.24; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; "i'm": 0.30; 'prints': 0.31; 'but': 0.35; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'john': 0.61; "you're": 0.61; 'approved': 0.65; 'therefore': 0.72; 'influence': 0.74; '"".': 0.84; 'god.': 0.84; 'right!': 0.84; 'surface': 0.84; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Beginner question
Date Tue, 04 Jun 2013 11:23:22 +0200
Organization None
References <323f2f5b-1f50-4689-90b8-74c411e43971@googlegroups.com> <vg3hahefhel.fsf@coffee.modeemi.fi> <1ba2ceec-f778-4c95-bf98-260fc48b4c3f@googlegroups.com> <CAPTjJmrM=ai3g2XXSSULYvxdJKhvoTe61PefFC3tc20i5ajhHA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084bb71.dip0.t-ipconnect.de
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2629.1370337801.3114.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370337801 news.xs4all.nl 15923 [2001:888:2000:d::a6]:43346
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46861

Show key headers only | View raw


Chris Angelico wrote:

> On Tue, Jun 4, 2013 at 5:57 PM, John Ladasky <john_ladasky@sbcglobal.net>
> wrote:
>> On Tuesday, June 4, 2013 12:45:38 AM UTC-7, Anssi Saari wrote:
>>
>>> BTW, did I get the logic correctly, the end result is random?
>>
>> You're right!  I'm guessing that's not what the OP wants?
> 
> I'm guessing that's exactly what the OP wants. This is a fairly
> classic programming puzzle; on the surface it appears that you have
> some influence on the outcome, but ultimately you're playing
> rock-paper-scissors with the Random Number God.

As it is written, don't you always win if you hit enter?
It may be the approved cheat code, though...

OP:

("some string")

is not a tuple, it is the same as just

"some string"

therefore

option1 = "some string"
if input() in option1:
    print("yes")

prints 'yes' if the user types in a substring of option1, and the shortest 
substring of any string is "".

For a single-item tuple the trailing comma is mandatory:

>>> ("some string") # string
'some string'
>>> "some string", # tuple
('some string',)
>>> ("some string",) # tuple, parens added for clarity
('some string',)

In general a tuple is consituted by the comma(s), not the parentheses:

>>> "one", "two"
('one', 'two')

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


Thread

Beginner question eschneider92@comcast.net - 2013-06-03 20:39 -0700
  RE: Beginner question Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-04 09:46 +0300
    Re: Beginner question John Ladasky <john_ladasky@sbcglobal.net> - 2013-06-04 00:53 -0700
      RE: Beginner question Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-04 11:17 +0300
  Re: Beginner question Anssi Saari <as@sci.fi> - 2013-06-04 10:45 +0300
    Re: Beginner question John Ladasky <john_ladasky@sbcglobal.net> - 2013-06-04 00:57 -0700
      Re: Beginner question Chris Angelico <rosuav@gmail.com> - 2013-06-04 18:24 +1000
      Re: Beginner question Peter Otten <__peter__@web.de> - 2013-06-04 11:23 +0200
      RE: Beginner question Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-04 14:23 +0300
        Re: Beginner question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-04 12:35 +0000
          RE: Beginner question Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-04 15:51 +0300
            Re: Beginner question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-07 02:21 +0000
      RE: Beginner question Fábio Santos <fabiosantosart@gmail.com> - 2013-06-04 12:34 +0100
      RE: Beginner question Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-04 14:53 +0300
        Re: Beginner question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-04 12:25 +0000
          RE: Beginner question Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-04 15:37 +0300
          RE: Beginner question Fábio Santos <fabiosantosart@gmail.com> - 2013-06-04 13:47 +0100
      RE: Beginner question Fábio Santos <fabiosantosart@gmail.com> - 2013-06-04 13:15 +0100
      Re: Beginner question Mitya Sirenef <msirenef@lightbird.net> - 2013-06-04 13:16 -0400
  Re: Beginner question Larry Hudson <orgnut@yahoo.com> - 2013-06-04 02:13 -0700
    Re: Beginner question Roy Smith <roy@panix.com> - 2013-06-04 09:16 -0400
  Re: Beginner question Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-04 20:43 +0100
  Re: Beginner question eschneider92@comcast.net - 2013-06-05 20:42 -0700

csiph-web