There is a long condition:

if j==465 or j==641 or j==465 or j==641 or j==638 or j==637 or j==644 or j==645 or j==648 or j==1120 or j==1122 or j==1124 и т.д. 

Can I simplify it somehow?

    3 answers 3

    Store all numeric values ​​in an array, and rewrite if:

     elements = [465, 641, ...] if j in elements: #do something 

      For this case, it is better to use sets:

       elements = frozenset([465,641,638,637,644,645,648,1120,1122,1124]) if j in elements: pass 
         if j in [465,641,638,637,644,645,648,1120,1122,1124] 
        • Well, 2 identical answers with a difference of 10 seconds) - metazet