Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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

Thanks in advance



 
Reply With Quote
 
 
 
 
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...
>
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how to count the total number of strings (in the list) used in Python? Chinesekidz Python 0 04-16-2012 07:03 PM
Count number of bits set in a number Mack C Programming 12 09-28-2007 09:31 AM
BT Total Broadband vs BT Business Total John Y UK VOIP 2 02-02-2007 09:27 AM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57