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

nn pruebauno at latinmail.com
Tue Apr 17 16:07:45 EDT 2012


On Apr 16, 3:00 pm, Chinesekidz <chinesek... 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:
>
> list:['1','2','3','4']
>
> for l in range(4):
>      num=input("list:"+list[l]+"(between 1 and 4):")
>      if num.isdigit:
>         tnum=tnum+int(num)
>
> print("Total number of list used:",???)
>
> I want the output to be:
>
> list 1 (between 1 and 4): 2
> list 2 (between 1 and 4): 5
> list 3 (between 1 and 4): 6
> list 4 (between 1 and 4):5
> list 1 (between 1 and 4):4
>
> Total number of list used: 5
>
> 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...
>
> Thanks in advance

I didn't understand the question. If you don't get any further answers
on the list it is because nobody else understood the question either.



More information about the Python-list mailing list