[Tutor] help

Steven D'Aprano steve at pearwood.info
Thu Jun 17 14:20:24 CEST 2010


On Thu, 17 Jun 2010 05:28:37 pm KB SU wrote:
> help

No no, don't tell us what you need help about! I love guessing games!

Let me see now... I'm guessing that your problem is that don't know how 
to work out the length of a string. Here's one way:

string = "something"
count = 1
for char in string:
    count *= 10

import math
print "The string has", math.log10(count), "characters."

 
There's probably a shorter way too.



-- 
Steven D'Aprano


More information about the Tutor mailing list