If statement ends program inside for loop -


i'm using python 3.3.2 , i'm writing program takes number, , adds list in ascending order. program works, added statement checks see if number user inputs in list, , when true, loop ends , program stops. can give me suggestions why is, , how prevent it?

l = float(input('input number: ')) #gets input user list1 = [l] #places first input in list  l in list1: #begins loop     l = input('input number: ') #more input      if l == ('stop'): #user tells program stop          print(list1)          break #ends program      elif l != ('stop'): #the user not stop program         l = float(l)          if l not in list1: #new input not in list             n = len(list1)#length of list             m = max(list1)#max value of list             m = min(list1)#min value of list              if l < m: #checks if input smaller min of list1                 list1.insert(0, l)#inserts new input @ start of list              elif l > m:#chacks if new input larger max of list1                 list1.append(l)#add new input @ ent of list1              elif l < m , l > m:#new input between max , min of list1                  x in range(0 , len(list1)):#x number of indexes in list1                      if l < list1[x]:#checks size of each index input                        list1.insert(x, l)#inserts input between upper , lower values                        break          elif l in list1: #checks if new input in list             print ('already in list!')      else: #program fails         print('i\'m afraid can\'t dave.')#lol         break 

thanks.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -