So lets say I have a a function defined like
def function(x):
list1 = []
while list1[-1] < x:
... (loop will generate a list of ints)
return list1
The while loop will generate a list of ints, and I want the while loop to run until the last element of the list being generated is < x.
I tried something like while list1[-1] < x
but obviously it returns an error on the first cycle because the list is empty at the beginning and the index is out of range.