I am trying to create an array and then clear it using a function, but the terminal keeps displaying 'list index out of range'.
duplicates = []
def ClearArray():
for index in range(100):
duplicates[index].append("")
ClearArray()
print(duplicates)
The instruction is to Initialise the global array Duplicates, which is a 1D array of 100 elements of data type STRING, and set all elements to empty string using a function.
duplicates = [[]]*100or a list of empty strings["" for _ in range(100)]? It is really unclear what the "array" is.duplicates[index].append("")withduplicates.append("")in your code