num=1
    tnum=0 #representing triangular number
    nof=0
    while nof<501:
          nof=2 #to include 1 and the number itself
          tnum+=num
          num+=1
          for i in range (2,int((tnum/2))+1):
              if tnum%i==0:
                 nof+=1
          print (tnum," : ",nof) #printing the triangular number and its number of divisors
    print ("Required number is ", tnum)

This code will also take a good amount of time to get you result.