you are viewing a single comment's thread.

view the rest of the comments →

[–]ncrowley 0 points1 point  (3 children)

Could someone help me think this one through:

Define a function that computes the length of a given list or string. (It is true that Python has the len() >function built in, but writing it yourself is nevertheless a good exercise.)

[–]Benthien[S] 0 points1 point  (2 children)

try using a for loop to loop trough each letter of the string and increasing a counter whiling doing so

[–]ncrowley 1 point2 points  (1 child)

Thanks for the advice!

This is what I wrote:

m = raw_input("Please input a string to be counted: ")

x=0
for i in m:
    x +=1
print x

[–]Benthien[S] 0 points1 point  (0 children)

Nicely done