Thursday , June 24 2021

How to find the average value of a list in python

To answer the question of:

Please help me understand the problems in my code

The problem is the lines

to count the votes
if the count> = 50:
average = sum (count) / len (count)

vote it's a list of integers. So, when you loop to count the votes, the value of to count it's an integer I've tested your code in both Python 3.6.3 and 2.7.10 and you can not even call it sum() is len () it works on an integer (both return to TypeError if you try).

It initializes average = []so you seem to expect average to contain a list, but also if sum (count) = count is len (count) = 1, then average contains an integer, not a list.

I'd be curious to know which version of Python you're using that allows this code to run without errors.

Corrections for these errors have already been provided.

Source link


  1. hyundai replacement key

    Wohh just what I was searching for, appreciate it for posting. I love your website!

  2. tadalafil tablets

    I am also commenting to let you know of the helpful encounter my friend’s daughter found reading through your web page. She figured out numerous issues, not to mention what it’s like to have an amazing giving mood to have most people really easily know selected impossible subject areas. You really exceeded our own expectations. Many thanks for imparting the invaluable, safe, explanatory and even easy thoughts on the topic to Janet.

  3. I enjoy you because of all your efforts on this site. Ellie enjoys doing internet research and it’s easy to see why. All of us hear all concerning the compelling means you deliver good information by means of the blog and as well cause contribution from other people about this concept plus my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You’re carrying out a dazzling job.

  4. I am just writing to make you understand what a really good experience my wife’s princess obtained using your webblog. She noticed some things, which included what it is like to possess an excellent teaching spirit to make others with no trouble learn about specific tortuous things. You undoubtedly surpassed readers’ expected results. Thanks for providing those productive, trusted, informative as well as unique tips on your topic to Mary.

  5. headache drugs list

    Thanks for your strategies. One thing really noticed is that often banks plus financial institutions know the dimensions and spending patterns of consumers plus understand that plenty of people max outside their cards around the trips. They correctly take advantage of this real fact and then start flooding a person’s inbox plus snail-mail box by using hundreds of no interest APR credit cards offers shortly when the holiday season closes. Knowing that when you are like 98% in the American general public, you’ll get at the one opportunity to consolidate financial debt and switch balances towards 0 rate credit cards. ooonmpp – headache drugs list

  6. drugs for alzheimer

    I am continually invstigating online for tips that can assist me. Thanks! drugs for alzheimer

  7. best over the counter viagra cost of viagra

  8. viagra over the counter walmart: viagra – best over the counter viagra

Leave a Reply

Your email address will not be published.