Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread Steven D'Aprano
On Sat, 15 Dec 2007 16:46:38 -0800, Dennis Lee Bieber wrote: > ... this becomes trivial... So trivial I'm going to include a solution, > even though it is a homework assignment... > inp = raw_input("Enter the sequence of 1 and 0: ") print inp > 1001101011101011101 print "The count is %s

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread [EMAIL PROTECTED]
On Dec 15, 10:39�am, [EMAIL PROTECTED] wrote: > First of all I'd like to thank you all for your advices. Before I check all > your hints I want to clarify what I'm trying to do. The question says > "write a function that takes a sequence of bits as an input and return how > many 1s are in the seque

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread Steven D'Aprano
On Sat, 15 Dec 2007 16:39:32 +, te509 wrote: > So what I want > to do is to write a generic version of a function that takes as an input > a sequence of 1s and 0s in any format. Given that there is an infinite number of possible formats, I suggest you lower your sights to something more prac

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread te509
First of all I'd like to thank you all for your advices. Before I check all your hints I want to clarify what I'm trying to do. The question says "write a function that takes a sequence of bits as an input and return how many 1s are in the sequence", nothing more. This is quite simple for string

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread [EMAIL PROTECTED]
On Dec 15, 8:33�am, [EMAIL PROTECTED] wrote: > Hi guys, > does anybody know how to convert a long > sequence of bits to a bit-string? I want to avoid this: > > >>> bit=0011010111011101011�11001 > >>> str(bit) > > '949456129574336313917039111707606

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread Steven D'Aprano
On Sat, 15 Dec 2007 14:33:04 +, te509 wrote: > Hi guys, > does anybody know how to convert a long sequence of bits to a > bit-string? Can you explain what you actually mean? For instance... x = 1234567890 x is now a long sequence of bits. > I want to avoid this: > bit=001101

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread Grant Edwards
On 2007-12-15, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >>> does anybody know how to convert a long sequence of bits to a >>> bit-string? >> >>Yes! > > Would you like to help, please? You'll have to define 'sequence of bits' and 'bit string' for us. The example you showed didn't really make

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread te509
>> does anybody know how to convert a long >> sequence of bits to a bit-string? > >Yes! Would you like to help, please? >> I would appreciate a prompt reply because I have a python assessment to >> submit. > >Good luck, you're lucky you've got the whole weekend :) That's not the only assignment I

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread Tim Chase
> does anybody know how to convert a long > sequence of bits to a bit-string? I want to avoid this: > bit=00110101110111010001 I do not think this does what you think it does... http://docs.python.org/ref/integers.html The lead

Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread Arnaud Delobelle
On Dec 15, 2:33 pm, [EMAIL PROTECTED] wrote: > Hi guys, Hi > does anybody know how to convert a long > sequence of bits to a bit-string? Yes! > > I would appreciate a prompt reply because I have a python assessment to > submit. Good luck, you're lucky you've got the whole weekend :) > Thanks,

Convert a sequence of bits to a bit-string

2007-12-15 Thread te509
Hi guys, does anybody know how to convert a long sequence of bits to a bit-string? I want to avoid this: >>> bit=00110101110111010001 >>> >>> str(bit) '949456129574336313917039111707606368434510426593532217946399871489' I would appreciate

Convert a sequence of bits to a bit-string

2007-12-15 Thread te509
Hi guys, does anybody know how to convert a long sequence of bits to a bit-string? I want to avoid this: >>> bit=00110101110111010001 >>> >>> str(bit) '949456129574336313917039111707606368434510426593532217946399871489' I would appreciate