Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Denis McMahon Newsgroups: comp.lang.python Subject: Re: I am out of trial and error again Lists Date: Fri, 24 Oct 2014 21:49:27 +0000 (UTC) Organization: A noiseless patient Spider Lines: 36 Message-ID: References: <3082ee74-3182-4ea5-9851-2b1326e5b34c@googlegroups.com> <9a1l4athfj10h7r3v69ddo95285n9cjlms@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 24 Oct 2014 21:49:27 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="66ffcfa4470a58bcddbdcd1913f98ab4"; logging-data="23528"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Ybvee7CRtNWSw7r21gUuv7qnGGJtN6a8=" User-Agent: Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2) Cancel-Lock: sha1:zgqXhTznqIG7VscUAh0IXFFlcYs= Xref: csiph.com comp.lang.python:79622 On Fri, 24 Oct 2014 15:07:06 -0400, Seymore4Head wrote: > On Fri, 24 Oct 2014 19:40:39 +0100, Mark Lawrence > wrote: > >>On 24/10/2014 19:20, Seymore4Head wrote: >>> I meant to type: >>> if y in range(1,10) doesn't work. >>> Sigh Sorry >>> >>> >>How many more times, state what you expect to happen and what actually >>happens. "doesn't work" is useless. Please read this http://sscce.org/ > > Good suggestion. > OK how is this? > It doesn't print what I expect. > Does it print what you expect? > > name="123-xyz-abc" > for x in name: > if x in range(10): > print ("Range",(x)) > if x in str(range(10)): > print ("String range",(x)) > > http://i.imgur.com/EGKUpAb.jpg I suspect you're discovering the difference between the python2 and python3 range() functions, and what happens when you encapsulate them in string. I've already posted about this once this evening. -- Denis McMahon, denismfmcmahon@gmail.com