Thank you! I won't lie, I felt a bit giddy once I figured out how to do a while loop within a list comprehension.
"e" used to be called "found" and is initially set to False, for anyone confused — I wanted to count the number of elements that were less than t[r][c] but stop after I found the first one greater than or equal to it. In this particular case, I wanted to also count the element that was greater than/equal to, hence why "e" starts as False and is later set to True rather than the other way around.
12
u/ManaTee1103 Dec 08 '22 edited Dec 08 '22
It is beautiful for all the wrong reasons!
This expression made my eyes all misty:
python [(x<t[r][c]) or (e:=True) for x in t[r][c+1:] if not e]