I am having trouble getting the string.count function to work. I want it to
count the amount of digits (0 or 1) in the string, but I keep getting an
error stating the string.count was expecting a character buffer object.
CODE:
count = string.count(conversion(n),["0","1"])
ERROR:
Traceback (most recent call last):
File "/Users/<name>/Desktop/Project 1.py", line 59, in -toplevel-
signed_mag()
File "/Users/<name>/Desktop/Project 1.py", line 29, in signed_mag
count = string.count(conversion(n),["0","1"])
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/string.py"
, line 348, in count
return s.count(*args)
TypeError: expected a character buffer object
I'm trying to make a decimal to binary converter that has the option to
select the amount of bits for Signed Binary. I've thought of a way (not
tested yet) on how to implement the bits, but I first need to count the
amount of digits in the original conversion. Thanks in advance.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor