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

C

Chinesekidz

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top