selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

driver.get(“GreenKart - veg and fruits kart”)
driver.find_element(By.CSS_SELECTOR, “.search-keyword”).send_keys(“ca”)
results = driver.find_elements(By.XPATH, “//div[@class=‘products’]/div”)
count = len(results)
assert count > 0
for result in results:
result.find_element(By.XPATH, “div/button”).click() #chaining of parent to child elements
driver.find_element(By.CSS_SELECTOR, “img[alt = ‘Cart’]”).click()
driver.find_element(By.XPATH, “//button[text()=‘PROCEED TO CHECKOUT’]”).click()
driver.find_element(By.CSS_SELECTOR, “.promoCode”).send_keys(“rahulshettyacademy”)
driver.find_element(By.CSS_SELECTOR, “promoBtn”).click()
driver.find_element(By.XPATH, “//button[text()=‘Place Order’]”).click()

Use the </> icon to format your code. Its in the cog-wheel menu.

Then the code will be like this:

def example():
     print('Hello world')

Please also include all of the error message you see.
There will be information, like line number that will help us to help you.