This question is about List Comprehension. However, the iterables are a bit complex so I am confused about how to write this List Comprehension.
So, I have Some pydantic class like this
class textbox(BaseModel):
x1: int
y1: int
x2: int
y2: int
class Page(BaseModel):
color: List[RGB]
textboxes: List[textbox]
class Notepad(BaseModel):
pages: List[Page]
Assuming all of them have appropriate values assigned to them. I want to do a List Comprehension like this so that I can access each of the Page separately and for every Page access each of the textbox and put them inside one list.
TotalTextBox = [textbox in textboxes for Notepad.pages[i].textboxes]
But I am facing a problem because List Comprehension is not letting me use the counter variable i. Can anyone please help me with this problem? Thank you.
P.S. I don't want to use enumerate. I want a simple list as result.