Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Mark Lawrence
On 01/12/2013 18:02, Reuben wrote: Thanks everyone for all the replies. No problem but please don't top post, it makes following long threads particularly difficult, thanks. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Reuben
Thanks everyone for all the replies. On Sun, Dec 1, 2013 at 11:29 PM, Joel Goldstick wrote: > > > > On Sun, Dec 1, 2013 at 12:53 PM, Mark Lawrence wrote: > >> On 01/12/2013 17:40, eryksun wrote: >> >>> On Sun, Dec 1, 2013 at 6:14 AM, Steven D'Aprano >>> wrote: >>> On Sun, Dec 01, 2013 at 0

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Reuben
I mean occurrence of 2 from numbers 1 to 100. The number could be the first digit or second digit in a two digit number..for e.g. In number 21 it appears as first digit. For number 92 it appears as second digit On 01-Dec-2013 2:45 PM, "Steven D'Aprano" wrote: > On Sun, Dec 01, 2013 at 11:20:02AM

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Reuben
I tried it with the python interpreter as mentioned below: test@test-Inspiron-1564:~/learn$ python Python 2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> On Sun, Dec 1, 2013 at 7:50 PM, Steven D'Apra

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread spir
On 12/01/2013 06:50 AM, Reuben wrote: Hi, How can we write a logic for detecting the number 2 in range from 1 to 100 Do you mean: if 2 in numbers: ? Also for a more general solution, think at the very nice function any(bools), in combination with a generator comprehension:

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Mark Lawrence
On 01/12/2013 17:59, Joel Goldstick wrote: On Sun, Dec 1, 2013 at 12:53 PM, Mark Lawrence mailto:breamore...@yahoo.co.uk>> wrote: On 01/12/2013 17:40, eryksun wrote: On Sun, Dec 1, 2013 at 6:14 AM, Steven D'Aprano mailto:st...@pearwood.info>> wrote: On Sun, Dec

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Joel Goldstick
On Sun, Dec 1, 2013 at 12:53 PM, Mark Lawrence wrote: > On 01/12/2013 17:40, eryksun wrote: > >> On Sun, Dec 1, 2013 at 6:14 AM, Steven D'Aprano >> wrote: >> >>> On Sun, Dec 01, 2013 at 02:57:33PM +0530, Reuben wrote: >>> I mean occurrence of 2 from numbers 1 to 100. The number could be the

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Mark Lawrence
On 01/12/2013 17:40, eryksun wrote: On Sun, Dec 1, 2013 at 6:14 AM, Steven D'Aprano wrote: On Sun, Dec 01, 2013 at 02:57:33PM +0530, Reuben wrote: I mean occurrence of 2 from numbers 1 to 100. The number could be the first digit or second digit in a two digit number..for e.g. In number 21 it

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread eryksun
On Sun, Dec 1, 2013 at 6:14 AM, Steven D'Aprano wrote: > On Sun, Dec 01, 2013 at 02:57:33PM +0530, Reuben wrote: >> I mean occurrence of 2 from numbers 1 to 100. The number could be the >> first digit or second digit in a two digit number..for e.g. In number 21 it >> appears as first digit. For n

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Steven D'Aprano
On Sun, Dec 01, 2013 at 08:43:46AM -0500, bruce wrote: > hmm... > > two questions. (new to cmdline py) > > tried typing in what was typed in above in the python shell: > > for i in range(1, 101): > print "2" in str(i) > > this did nothing.. Curious. Which Python shell did you use? I would

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Mark Lawrence
On 01/12/2013 05:50, Reuben wrote: Hi, How can we write a logic for detecting the number 2 in range from 1 to 100 Regards, Reuben Paper and pen or pencil should be perfectly adequate for this task. Alternatively, open an editor, type some code, run it, if you have problems ask another que

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Steven D'Aprano
On Sun, Dec 01, 2013 at 02:57:33PM +0530, Reuben wrote: > I mean occurrence of 2 from numbers 1 to 100. The number could be the > first digit or second digit in a two digit number..for e.g. In number 21 it > appears as first digit. For number 92 it appears as second digit The most efficient way i

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Steven D'Aprano
On Sun, Dec 01, 2013 at 11:20:02AM +0530, Reuben wrote: > Hi, > > How can we write a logic for detecting the number 2 in range from 1 to 100 2 in range(1, 101) -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

Re: [Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Amit Saha
Hello, On Sun, Dec 1, 2013 at 3:50 PM, Reuben wrote: > Hi, > > How can we write a logic for detecting the number 2 in range from 1 to 100 You question is unclear. Could you please give more details ? Best, Amit. -- http://echorand.me ___ Tutor mai

[Tutor] Occurrence of number 2 in a range from 1 to 100

2013-12-01 Thread Reuben
Hi, How can we write a logic for detecting the number 2 in range from 1 to 100 Regards, Reuben ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor