title: Python - Any way to avoid several if-statements inside each other in a for-loop?
body: <p>I need a better way to do this. I'm  new with programming but I know that this is a very inefficient way of doing it and that I need a function for this, I just don't know how to do it exactly. any suggestions? I'm VERY grateful for any help! </p>
  
  <pre><code>for H in range(0,len(a_list)):
      if a_list[H] &gt; list4[0]:
          list5 = [number_list[i]]
          if function(list1,list5) == list1[1]:
              if function(list2,list5)== list2[1]:
                  if function(list3,list5)== list3[1]:
                      if function(list4,list5)== list4[1]:
                          list5.append(input('some input from the user'))
                          other_function(list5)
                          if list5[1]== 40:
                              print ('something something')
                              break out of EVERY loop 
                           else: 
                              for H in range(0,len(a_list)):
                                  if a_list[H] &gt; list5[0]:
                                      list6 = [number_list[i]]
                                      if function(list1,list6) == list1[1]:
                                          if function(list2,list6)== list2[1]:
                                              if function(list3,list6)== list3[1]:
                                                 if function(list4,list6)== list4[1]:
                                                    if function(list5,list6)== list5[1]:
                                                       list6.append(input('some input from theuser'))
                                                       other_function(list6)
                                                           if list6[1]== 40:
                                                               print ('something something')
                                                                   break out of EVERY loop 
                                                           else: 
                                                              etc. (one extra comparison every time)  
  </code></pre>