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

Chinesekidz chinesekidz at googlemail.com
Mon Apr 16 15:00:17 EDT 2012


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






More information about the Python-list mailing list