title: How to include a lot of decision making loops for checking a number within a range in a correct way?
body: <p>I am trying to solve a question to generate a list of numbers from a given range by making each number passed through a set of rules to get that number added in the list. Also to find the maximum element from the list.</p>
  
  <p>This is the actual question:
  Write a python program which finds the maximum number from num1 to num2 (num2 inclusive) based on the following rules.</p>
  
  <ol>
  <li>Always num1 should be less than num2</li>
  <li>Consider each number from num1 to num2 (num2 inclusive). Populate the number 
  into a list, if the below conditions are satisfied
  a)Sum of the digits of the number is a multiple of 3
  b)Number has only two digits
  c)Number is a multiple of 5</li>
  <li>Display the maximum element from the list</li>
  </ol>
  
  <p>In case of any invalid data or if the list is empty, display -1.</p>
  
  <p>First of all, I am new to Python and not familiar to solve these type of complex problems. So I think I made a lot of silly mistakes.</p>
  
  <pre><code>def find_max(num1, num2):
  
      max_num=-1
      num_list=[] #list declared
      if(num1&lt;num2): #to check num1 &lt; num2 as said in the question
          for numbers in range(int(num1),int(num2)+1): #for numbers from the range
              tot=0
              count=0
              while(numbers&gt;0): 
                  digit=numbers%10
                  tot=tot+digit #to generate sum of digits
                  numbers=numbers//10 
                  count=count+1 #to count the number of digits
                  if(tot%3==0 and count==2 and numbers%5==0): 
                      num_list.append(numbers) #to generate the list
                  else:
                      print(-1)
      else:
          print(-1)
      max_num = max(num_list) #to find the maximum value in the list
      return max_num
  
  #Provide different values for num1 and num2 and test your program.
  max_num=find_max(10,15)
  print(max_num)
  </code></pre>
  
  <p>Results I am getting :
  -1
  -1
  -1........</p>