how to count the total number of strings (in the list) used in Python?

Chris Angelico rosuav at gmail.com
Mon Apr 16 19:12:43 EDT 2012


On Tue, Apr 17, 2012 at 5:03 AM, Chinesekidz <chinesekidz at googlemail.com> wrote:
> Hello!
>
> I would like to know how to write the program to count the total
> number of strings (in the list) used in Python..
>
> for example:
> [broken example snipped]
> in the case above, it is to show the how many times of strings from
> the list has been used...
>
> I would like to know how to write the code for this...

Your request is a little unclear, and your example code doesn't do
what you think it does. What exactly do you mean by the number of
times the string has been used? What makes the loop "use" a string
more than once? With your given iteration, it will always loop over
the elements exactly once.

Chris Angelico



More information about the Python-list mailing list