title: I have to find the maximum difference between the prime numbers in the given range. please help me out
body: <p>Prime Game (100 Marks)</p>
  <p>Rax, a school student, was bored at home in the pandemic. He wanted to play but there was no one to play with. He was doing some mathematics questions including prime numbers and thought of creating a game using the same. After a few days of work, he was ready with his game. He wants to play the game with you.</p>
  <p>GAME:</p>
  <p>Rax will randomly provide you a range [ L , R ] (both inclusive) and you have to tell him the maximum difference between the prime numbers in the given range. There are three answers possible for the given range.</p>
  <p>There are two distinct prime numbers in the given range so the maximum difference can be found.</p>
  <p>There is only one distinct prime number in the given range. The maximum difference in this case would be 0.</p>
  <p>There are no prime numbers in the given range. The output for this case would be -1.</p>
  <p>To win the game, the participant should answer the prime difference correctly for the given range.</p>
  <p>Example:</p>
  <p>Range: [ 1, 10 ]</p>
  <p>The maximum difference between the prime numbers in the given range is 5.</p>
  <p>Difference = 7 - 2 = 5</p>
  <p>Range: [ 5, 5 ]</p>
  <p>There is only one distinct prime number so the maximum difference would be 0.</p>
  <p>Range: [ 8 , 10 ]</p>
  <p>There is no prime number in the given range so the output for the given range would be -1.</p>
  <p>Can you win the game?</p>
  <p>Input Format
  The first line of input consists of the number of test cases, T</p>
  <p>Next T lines each consists of two space-separated integers, L and R</p>
  <p>Constraints
  1&lt;= T &lt;=10</p>
  <p>2&lt;= L&lt;= R&lt;=10^6</p>
  <p>Output Format
  For each test case, print the maximum difference in the given range in a separate line.</p>
  <p>Sample TestCase 1</p>
  <p>Input</p>
  <p>5</p>
  <p>5 5</p>
  <p>2 7</p>
  <p>8 10</p>
  <p>10 20</p>
  <p>4 5</p>
  <p>Output</p>
  <p>0</p>
  <p>5</p>
  <p>-1</p>
  <p>8</p>
  <p>0</p>
  <p>Explanation</p>
  <p>Test Case 1: [ 5 - 2 ] = 3</p>
  <p>Test Case 2: [ 7 - 2 ] = 5</p>
  <p>Test Case 3: No prime number in the given range. Output = -1</p>
  <p>Test Case 4: [ 19 - 11 ] = 8</p>
  <p>Test Case 5: The difference would be 0 since there is only one prime number in the given range.
  This is my Python3 code:
  Explain Your problem here</p>
  <pre><code>def main():
      testCase = int(input())
  
      while testCase&gt;0:
          LR = list(map(int,input().strip().split()))
          L = LR[0]
          R = LR[1]
          lst=[]
          flag=1
          for i in range(L,R+1):
              flag=1
              for j in range(2,i):
                  if i%j==0:
                      flag=-1
                      break
              if flag == 1:
                             
                  lst.append(i)
  
          n=len(lst)
          if n&gt;1:
              print(max(lst)-min(lst))
          elif flag==-1:
              print(-1)
          else:
              print(0)
          testCase -=1
   
  </code></pre>
  <p>for further explanation: <a href="https://www.techgig.com/codegladiators/question/cVFhTUIxZWZJYXF0ZWlJM0loQUtvT0pybVRNREFidVFLUW5udlI1Mk1wQnp5d1dnKzhLclZDOFJCK2wrbnltLw==/1?msg_type=1" rel="nofollow noreferrer">https://www.techgig.com/codegladiators/question/cVFhTUIxZWZJYXF0ZWlJM0loQUtvT0pybVRNREFidVFLUW5udlI1Mk1wQnp5d1dnKzhLclZDOFJCK2wrbnltLw==/1?msg_type=1</a></p>