Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!goblin1!goblin.stu.neva.ru!news.astraweb.com!border6.a.newsrouter.astraweb.com!cyclone01.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!npeersf04.am4!fx07.am4.POSTED!not-for-mail From: alister Subject: Re: I am out of trial and error again Lists Newsgroups: comp.lang.python References: <2412654f-ac5e-4678-8956-afc4e27affb3@googlegroups.com> User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 57 Message-ID: NNTP-Posting-Host: 82.9.78.47 X-Complaints-To: http://netreport.virginmedia.com X-Trace: 1414184873 82.9.78.47 (Fri, 24 Oct 2014 21:07:53 UTC) NNTP-Posting-Date: Fri, 24 Oct 2014 21:07:53 UTC Organization: virginmedia.com Date: Fri, 24 Oct 2014 21:07:53 GMT X-Received-Body-CRC: 1618078324 X-Received-Bytes: 2696 Xref: csiph.com comp.lang.python:79617 On Fri, 24 Oct 2014 16:58:00 -0400, Seymore4Head wrote: > On Fri, 24 Oct 2014 20:37:31 +0000 (UTC), Denis McMahon > wrote: > >>On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: >> >>> I tried list(range(10) >> >>This is missing a ")" >> >>It probably sat there waiting for you to finish the line. >> >>list(range(10)) >> >>You have two "(" in the line, you need two ")" to match them. >> >>> I thought that would work in Python 3. It didn't. >> >>It does if you enter it properly. >> >>also try: >> >>str(list(range(10))) >> >>Note that that has three "(" and three ")" on the line. > > I make lots of typing mistakes. It is not that. Did you see the short > example I posted? > > 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)) > > It doesn't throw an error but it doesn't print what you would expect. it prints what "I" expect, it probably does not print what you expect you have may times been told that str(range(10)) does not do what you expect but you keep failing to test you think that it crates a list of strings ['1','2','3'....] but it does not it creates a list & then turns the whole list into a string '[1,2,3...]' people are suggesting you try this things in the interactive prompt because doing teaches far better than just reading. -- Honesty's the best policy. -- Miguel de Cervantes