hi all,
i have a function which returns a string. for eg: X='101110'. i want to search
for 0 and highlight the location.
i am thinking of defining X as a list. but how can i split 101110 as there are
no spaces in between? i'm thinking if i can put it into a list:
X=['1','0','1','1','1','0'],
On 8 February 2011 16:20, tee chwee liong wrote:
> hi all,
>
> >i have a function which returns a string. for eg: X='101110'. i want to
> search for 0 and highlight the location.
> i> am thinking of defining X as a list. but how can i split 101110 as there
> are no spaces in between? i'm thinkin
On 08/02/2011 11:20, tee chwee liong wrote:
hi all,
i have a function which returns a string. for eg: X='101110'. i want
to search for 0 and highlight the location.
i am thinking of defining X as a list. but how can i split 101110 as
there are no spaces in between? i'm thinking if i can put it
Eric Stevens wrote:
Hi:
I am relatively new to Python and have been recently trying to experiment
with its zipfile capabilities. However, everytime I try to open a zip (
using method zipfile.ZipFile(open('zipfile.zip','r')) ) I continue to get an
error message that states:error: unpack requires
tee chwee liong wrote:
hi all,
i have a function which returns a string. for eg: X='101110'. i want
to search for 0 and highlight the location. i am thinking of defining
X as a list. but how can i split 101110 as there are no spaces in
between? i'm thinking if i can put it into a list:
X=['1','0
> To get a list, just ask for one:
>
list("abcd")
> ['a', 'b', 'c', 'd']
>
or., and this isn't to argue with anyone;), you could:
>>> x = 'abcd'
>>> y = []
>>> for letter in x:
... y.append(letter)
...
>>> print y
['a', 'b', 'c', 'd']
which explains that the list is derived from the st
On 8 February 2011 04:44, Alexander Fairley wrote:
> Some high profile ruby hackers have put together a pretty snazzy set of
> vim/gvim configs together on github at
>
> https://github.com/carlhuda/janus
>
>
Thank you, but I think this only works on OSX? I use Ubuntu and if I
understand your link
Nevins Duret wrote:
A good friend of mine locked herself out of her computer and forgot her
password. I pretty much scoured the internet as
a resource only to hit a brick wall. I tried using ophcrack version 2.3.1
in order to obtain the password and felt completely at home
being that it was
hi all,
thanks for the advice. i modified my code to be:
c=('01101')
i=-1
try:
while 1:
i=c.index('0',i+1)
print "Lane fail",i
except ValueError:
print "All Lanes PASS"
pass
when i run, the result is:
>>>
Lane fail 0
Lane fail 3
All Lanes PASS
Qu
Don't use the try and except, use a if else. I'm not as good as an
explainer as the pros, but I can make enough sense if you respond back
with a useful set of examples you've tried.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscrip
On 08/02/2011 15:04, tee chwee liong wrote:
hi all,
thanks for the advice. i modified my code to be:
c=('01101')
i=-1
try:
while 1:
i=c.index('0',i+1)
print "Lane fail",i
except ValueError:
print "All Lanes PASS"
pass
when i run, the result is:
>>>
Lane fail 0
Lane
On Tue, Feb 8, 2011 at 8:36 AM, Christian Witts wrote:
> On 08/02/2011 15:04, tee chwee liong wrote:
>>
>> hi all,
>>
>> thanks for the advice. i modified my code to be:
>>
>> c=('01101')
>> i=-1
>> try:
>> while 1:
>> i=c.index('0',i+1)
>> print "Lane fail",i
>> except ValueError
On 08/02/2011 15:38, David Hutto wrote:
On Tue, Feb 8, 2011 at 8:36 AM, Christian Witts wrote:
On 08/02/2011 15:04, tee chwee liong wrote:
hi all,
thanks for the advice. i modified my code to be:
c=('01101')
i=-1
try:
while 1:
i=c.index('0',i+1)
print "Lane fail
Christian Witts wrote:
> On 08/02/2011 15:04, tee chwee liong wrote:
>> hi all,
>>
>> thanks for the advice. i modified my code to be:
>>
>> c=('01101')
>> i=-1
>> try:
>> while 1:
>> i=c.index('0',i+1)
>> print "Lane fail",i
>> except ValueError:
>> print "All Lanes PASS"
On Tue, Feb 8, 2011 at 2:47 PM, Christian Witts
>>> `while i< len(c)` instead of `while 1`
>>>
>>
>> You remind me of me...like it was yesterday. Explanations with no
>> thought. Unimpressive isn't it?
>>
>
> While the index is smaller than the length of the string do your processing.
> It reads
Visit http://www.cracktheinterview.org/ for more interview preparation tips and
interview experiences of various people
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Mon, 7 Feb 2011, Eric Stevens wrote:
Hi:
I am relatively new to Python and have been recently trying to experiment
with its zipfile capabilities. However, everytime I try to open a zip (
using method zipfile.ZipFile(open('zipfile.zip','r')) ) I continue to get an
error message that states:e
Sorry folks,
I meant to hit discard on this one but clicked Accept by mistake.
Alan G.
List moderator
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
"tee chwee liong" wrote
i have a function which returns a string. for eg: X='101110'.
i want to search for 0 and highlight the location.
I'm not sure what you mean by highlight the location.
Is it a GUI? Are you colour coding the characters?
i am thinking of defining X as a list.
You
> I'm not sure what you mean by highlight the location.
> Is it a GUI? Are you colour coding the characters?
>
hi,
no it is not GUI. i just want to know where is the location of the 0 in the
returned string. For eg: 10111, i want to say 0 is at lane 3 (calculating
location from right to le
> `while i < len(c)` instead of `while 1`
>
hi,
i modified codes to be i>>
Lane fail 0
Lane fail 3
All Lanes PASS
>>>
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options
"tee chwee liong" wrote
###
c=('01101')
i=-1
try:
while i print "Lane fail",i
except ValueError:
print "All Lanes PASS"
pass
#
The first thing is that you never increment i so the
while condition is never going to terminate, so its
probably just
hi all,
the code works:
s='00101'
found = False
for i,c in enumerate(s):
if c == '0':
print 'Lane fail',i
found = True
if not found: print 'All lanes PASS
#
Result:
>>>
Lane fail 0
Lane fail 1
Lane fail 3
>>>
the enumerate is checking from left to right. is
23 matches
Mail list logo