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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:09:15+00:00 2026-05-15T17:09:15+00:00

#hello , i wounder why my code keep stoping at the secound while loop

  • 0

#hello , i wounder why my code keep stoping at the secound while loop and doesn’t do anything

print"*******************************"
a = 0
deg_list =[]
deg_list_a=[]
deg_list_b=[]
deg_list_c=[]
degree=input("Enter the students Degree:")
while a<=degree:
    deg_list.append(degree);
    degree=input("Enter the students Degree:")
print "Degree List :",deg_list
print len(deg_list)
while len(deg_list)>=0:
    if deg_list[a]>=16:
        deg_list_a.append(deg_list[a])
        x=+1
    elif 15>deg_list[a]>=10:
        deg_list_b.append(deg_list[a])
        x=+1
    else :
        deg_list_b.append(deg_list[a])
        x=+1
print deg_list_a
print deg_list_b
print deg_list_c
  • 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-15T17:09:16+00:00Added an answer on May 15, 2026 at 5:09 pm

    Your code enters an endless loop.

    Both of your while loops have problems with the condition which allows them to terminate. Since your code never changes the value of a, the first loop becomes while 0<=degree, and so the first loop terminates when the user inputs a negative value. But the variable a can be removed from your program.

    The while loop continues as long as len(deg_list) >= 0. However, no code within the loop decreases the length of deg_list, so the while loop continues forever.

    The code below could help you get this working:

    deg_list =[]
    deg_list_a=[]
    deg_list_b=[]
    deg_list_c=[]
    degree=input("Enter the students Degree:")
    while degree > 0:
        deg_list.append(degree);
        degree=input("Enter the students Degree:")
    print len(deg_list)
    while len(deg_list) > 0:        # Strictly greater than 0, not equal to 0.
        if deg_list[0] >= 16:
            # Use pop to access first element
            deg_list_a.append(deg_list.pop(0))    
        elif deg_list[0] >= 10:    # One comparison per statement, only.
            deg_list_b.append(deg_list.pop(0))
        else:
            deg_list_c.append(deg_list.pop(0))  # c, not b.
    print deg_list_a
    print deg_list_b
    print deg_list_c           
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was helping a friend to write some Java code, who doesn't know a
I wonder why this code does not work as expected: @ECHO off SET S1=HELLO
Hello I have next JS code (this code not my own) function somename(f) var
So...I have the following code: int main(void) { const char *s=hello, world; cout<<&s[7]<<endl; return
Hello I have written the following code. My objective was to write a function
Hello I made a simple racket program on windows xp sp3 I wonder how
Hello, I want to put custom status bar in notification window of iphone. is
Hello I did login as a super admin in the front en of joomla
Hello! I've been programming for a long time but just started developing for android,
Hello all I am working on javascript jquery and svg.I want to ask a

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.