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

  • Home
  • SEARCH
  • 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 1104407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:28:47+00:00 2026-05-17T01:28:47+00:00

Hai… i am facing a problem while inserting values to an array. the programming

  • 0

Hai…
i am facing a problem while inserting values to an array. the programming language using is python. the problem is, i need to insert a value to array after performing a division. but every the value in array is always 0.0 .
i am attaching the code here….

print len(extract_list1)
ratio1=range(len(extract_list1))
i=0
for word in extract_list1:
 ratio1[i]=float(i/len(extract_list1))
 print extract_list1[i],ratio1[i]
 i+=1
ratio2=range(len(extract_list2))
i=0
for word in extract_list2:
 ratio2[i]=float(i/len(extract_list2))
 print extract_list2[i],ratio2[i]
 i+=1
  • 1 1 Answer
  • 0 Views
  • 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-17T01:28:48+00:00Added an answer on May 17, 2026 at 1:28 am

    My best guess is that you are performing integer division and then converting to a float yielding the value of 0.0 which is what gets stuck in the list. you want to convert to float before the division. Sift through that wall of code and find out

    1. where you are inserting the value into the list.
    2. Where that value is generated.

    then post the code that generates the value. If the value is making it into the list (and you seem to indicate that it is), then this has nothing to do with lists and everything to do with how you are generating the value.


    As Roger Pate points out in the comments, you can place the line from __future__ import division as the very first line of your source code (or the first line after the encoding if you are using one) and it will automatically convert all division to floating point division. you can then use // as an operator for when you explicitly want truncating integer division.


    looking at your code, the problem is

    float(i/len(extract_list2))
    

    this should be

    float(i)/len(extract_list2))
    

    also, because you are taking the lengths of extract_list2 and extract_list1 multiple times, it would be better to create variables to store them.

    L1 = len(extract_list1)
    L2 = len(extract_list2)
    

    you can then reference the variables as long as you are not changing the lengths of the lists. This will save you some function calls and make your code more concise and readable.

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

Sidebar

Related Questions

Hai i developed a application using broadcast receiver.I need to wake my Application always.so
Hai tried to get the latitude and longtitude value using service class.my service function
Hai all I am new in android programming..... For my application I am using
Hai i am new bie to Android. i need to check the network connection
Hai I have an application which is designed in netbeans6.0.1 where i need to
Hai Guys, How to get wan ip address of my user using php....
Hai All, I'm developing the application using .net 2008 and Oracle 10g as database.
Hai I am developing a standalone application using Java in which I am using
Hai am Calling the webservice in my android application am using android version(r-18).but i
Hai am trying to get the gps location using BroadCast Receiver.its working fine,But i

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.