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

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

Chinesekidz
Guest
Posts: n/a

 04-16-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...

nn
Guest
Posts: n/a

 04-17-2012
On Apr 16, 3:00*pm, Chinesekidz <chinesek...@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...
>

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.