#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
Your code enters an endless loop.
Both of your
whileloops have problems with the condition which allows them to terminate. Since your code never changes the value ofa, the first loop becomeswhile 0<=degree, and so the first loop terminates when the user inputs a negative value. But the variableacan 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 ofdeg_list, so thewhileloop continues forever.The code below could help you get this working: