[Tutor] String module; Count

Kent Johnson kent37 at tds.net
Wed Oct 17 23:41:33 CEST 2007


ddm2 at sfu.ca wrote:
> 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"])

If conversion(n) is already a string containing only 0 and 1 you could 
just use  len(conversion(n))

Kent


More information about the Tutor mailing list