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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:33:45+00:00 2026-06-12T06:33:45+00:00

The program is supposed to take as input a list and return the index

  • 0

The program is supposed to take as input a list and return the index of the values less than 0.

I’m not allowed to use for loops, however. I have to do it using a while loop.

For example, if my function were named findValue(list) and my list was [-3,7,-4,3,2,-6], it would look something like this:

>>>findValue([-3,7,-4,3,2,-6])

would return

[0, 2, 5]

So far, I have tried:

def findValue(list):
    under = []
    length = len(list)
    while length > 0:
        if x in list < 0:       #issues are obviously right here.  But it gives you
            under.append(x)     #an idea of what i'm trying to do
        length = length - 1
    return negative
  • 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-06-12T06:33:46+00:00Added an answer on June 12, 2026 at 6:33 am

    I made some small changes to your code. Basically I’m using a variable i to represent the index of element x in a given iteration.

    def findValue(list):
        result = []
        i = 0
        length = len(list)
        while i < length:
            x = list[i]
            if x < 0:      
                result.append(i)
            i = i + 1 
        return result
    
    print(findValue([-3,7,-4,3,2,-6]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The program is supposed to take a file, say data.dat, filled with a list
I am writing a program in C++ which is supposed to take an input
I have a program that's supposed to take values and print them back out.
The program is supposed to take user input, turn it into html and pass
I have recently made a program that is supposed to take two environment variables,
I wrote this little program to practice arrays, which is supposed to take in
So, this program is supposed to take stats from Auburn's football season and compute
I have a button in my program that, when pressed, is supposed to take
I'm writing a little program for a beginner C++ class, I'm supposed to take
I've been trying forever to get this working. The program is supposed to take

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.