Neil Cerutti wrote:
On 2007-08-22, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
While it is desireable to not only write working, but also
aesthetically pleasing code, as a beginner you shouldn't worry
too much. The sense of aesthetics develops with time. Important
is to try and grasp the idio
On 2007-08-22, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> While it is desireable to not only write working, but also
> aesthetically pleasing code, as a beginner you shouldn't worry
> too much. The sense of aesthetics develops with time. Important
> is to try and grasp the idioms of the language
Amit Khemka wrote:
> On 8/22/07, james_027 <[EMAIL PROTECTED]> wrote:
>> hi Paul,
>>
>>> That doesn't crash or anything like that, but it also doesn't
>>> set the index variable, which can cause confusion in some situations.
>> Thanks for your quick answer ... Actually I was thinking how do I
>> ac
Here's another simple method:
l = ['j', 'a', 'm', 'e', 's']
counter = 0
for i in l:
# Do your code
counter += 1
print counter
Yrs,
Eric
> l = ['j', 'a', 'm', 'e', 's']
>
> for i in l
> # i want to know the nth number of times it has loop thru or
> something like counter?
>
> Thanks
james_027 schrieb:
> hi,
>
>> Oh I see. You have to combine a couple of concepts but for this
>> example you'd say:
>>
>>name = 'james' # 'l' looks too much like the digit 1
>>for i,c in enumerate(name):
>> print i, c
>>print i
>>
>> enumerate(name) generates the sequence
>>
hi,
> Oh I see. You have to combine a couple of concepts but for this
> example you'd say:
>
>name = 'james' # 'l' looks too much like the digit 1
>for i,c in enumerate(name):
> print i, c
>print i
>
> enumerate(name) generates the sequence
>
>(0,'j'), (1,'a'), (2,'m'),
james_027 <[EMAIL PROTECTED]> writes:
> Yes i am new to python :). I am sorry I should be clarify myself ...
> for example
>
> l = ['j', 'a', 'm', 'e', 's']
>
> for i in l
> # i want to know the nth number of times it has loop thru or
> something like counter?
Oh I see. You have to combine a c
On 8/22/07, james_027 <[EMAIL PROTECTED]> wrote:
> hi Paul,
>
> >
> > That doesn't crash or anything like that, but it also doesn't
> > set the index variable, which can cause confusion in some situations.
>
> Thanks for your quick answer ... Actually I was thinking how do I
> access the index insi
hi,
> It sounds like you're just starting to learn the language... have you
> read the online tutorial yet? That is a pretty easy introduction.
>
> See:http://python.org/doc/
>
> Anyway, you can say
>
>for i in (1,2,3):
> print i*5
>
> to print 5, 10, and 15 on separate lines, for examp
james_027 <[EMAIL PROTECTED]> writes:
> Thanks for your quick answer ... Actually I was thinking how do I
> access the index inside a for statement? Can you help
It sounds like you're just starting to learn the language... have you
read the online tutorial yet? That is a pretty easy introduction.
hi Paul,
>
> That doesn't crash or anything like that, but it also doesn't
> set the index variable, which can cause confusion in some situations.
Thanks for your quick answer ... Actually I was thinking how do I
access the index inside a for statement? Can you help
Thanks
james
--
http://mai
james_027 <[EMAIL PROTECTED]> writes:
> for i in []:
> #do something
> is this safe? or should I put a if statement to test it first?
That doesn't crash or anything like that, but it also doesn't
set the index variable, which can cause confusion in some situations.
--
http://mail.python.org/mail
hi,
I need to do some for loop on iterables which could be empty
sometimes, for example
a_list = []
for i in a_list:
#do something
is this safe? or should I put a if statement to test it first?
Thanks
james
--
http://mail.python.org/mailman/listinfo/python-list
13 matches
Mail list logo