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 4253208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:54:55+00:00 2026-05-21T04:54:55+00:00

I have 2 lists: first is list that I need to work with and

  • 0

I have 2 lists: first is list that I need to work with and the second is list of -1.
First of all I need to find the remainder of the divison of the number (number is len(lst)) and put it to the position (remainder of the divisor) in the list of -1. If there is already element, then to the next position in the list (if the next position is not empty, to the next and so on until it finds a position). How to realize the part that is in bold?

# -*- coding: utf-8 -*-
def fun(lst):
    count = [-1] * (len(lst) + 1)
    jar = []
    for i in range(len(lst)):
        jar.append(lst[i]%(len(lst) + 1))
        if count[jar[i]] == -1:
            count[jar[i]] = jar[i]
        else:
            arv[jar[i] + 1] = jar[i] # problem starts here
    print jar 

lst = [26, 53, 12, 65, 39, 6]
lst = fun(lst)
  • 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-21T04:54:55+00:00Added an answer on May 21, 2026 at 4:54 am

    You introduce arv, but you never assigned it a dict. Since it is a dict, assign arv as:

    arv = {}
    

    I would also use:

    for i,elem in enumerate(lst):
    

    You can now iterate over lst, while also knowing its position.

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

Sidebar

Related Questions

I have two Lists, the firs (right) represents a list of all cars and
I have a nested ul/li list <ul> <li>first</li> <li>second <ul> <li>Third</li> </ul> </li> ...
If you have a standard ordered list in HTML like: <ol> <li>First</li> <li>Second</li> <ol>
I have two ListBoxes. First ListBox items are list of Products. and second ListBox
I have a list that I need sorted by two fields. I've tried using
I need write a set of clauses that take a list of integer lists
All I need is to create a file that contains a file names' list
I have two list on my request on jsp. First one is productGroupName, and
I have a list of objects of type A. In a first iteration I
I have a list of tuple, the list was sorted based on the first

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.