'While loop for Python-Selenium Xpath not working?

I want to loop through years and months on a webpage, and I created this while loop with a flag to attempt so:

   active = True
   a = 1

   while active:
       a += 1
       driver.find_element_by_xpath("/html/body/div[1]/form/div[3]/main/div/div/div[3]/div/div/div[4]/div[3]/div/div/div[4]/select/option[a]").click() #option[a] the variable

   if a == 135:
       active = False

When I do this it fails. How do I properly write this code and incorporate the value of a in the Xpath? All help is appreciated. Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source