Why This Code Returns "List Index out of Range" Error
I Can't Work out Why This Code Is Returning a "List Index out of Range Error. Any Suggestions? Img = None Data_Values = ['2', '3', '4', '5'] Print("Before...
I can't work out why this code is returning a "list index out of range error. Any suggestions ?
img = None
data_values = ['2', '3', '4', '5']
print("before condition: ", data_values, type(data_values), len(data_values))
try:
if any(value in data_values for value in ('20', '42')) or (img is not None):
print("after condition")
form_data_values[f'{question}'] = form_data
except Exception as e:
print(e)
here is the output of that code:
before condition: ['2', '3', '4', '5'] <class 'list'> 4
list index out of range