Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6757405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:38:51+00:00 2026-05-26T13:38:51+00:00

I have a list of integer percentages which I need to print using the

  • 0

I have a list of integer percentages which I need to print using the following pattern:

The index of a value, a tab (8 spaces), a '*' printed for each percentage point

also if the value for an index is 0, print ‘less than 1 percent’

I have tried this code:

for b in new_tally:
    if b > 0:
        print new_tally[b], \t, '*' * b
    else:
        print 'Less than 1% of words had this length'

However I keep getting the error code: list index out of range.

I do not understand this at all, can someone point out what I have done wrong?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:38:51+00:00Added an answer on May 26, 2026 at 1:38 pm

    I think the code you wanted was:

    >>> new_tally = [5, 7, 8, 6, 4, 2]
    >>> for i, b in enumerate(new_tally, 1):
            print i, ':', b, '*' * b
    
    1 : 5 *****
    2 : 7 *******
    3 : 8 ********
    4 : 6 ******
    5 : 4 ****
    6 : 2 **
    

    The cause of the original traceback is that list members are looked up using square brackets instead of parentheses. new_tally(i) is a function call. new_tally[i] is an indexed lookup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following List<int> collection and I need to find the highest integer
I have a private method which take a list of integer value returns me
I have a list of integer ASCII values that I need to transform into
I have a List of (integer)ID's, which i am storing as text, like 23;45;67;12;332;783;123;33;15;87;41;422;88;58;
I have a List of HashMap 's which has key of type Integer and
i have two List A,B which consists integer values ,list A contains 40 to
For example I have a List<Integer> object with the following: 3, 6, 5, 3,
I have to pull a list of integer IDs from a table using only
I have an integer list which should be used as indices of another list
I have a List of integer's with duplicate values in it. What I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.