I am writing a Python program to measure the time complexity of insertion sort. However, I got the above mentioned error on line number 6. This error also occurs during other{ int(inputs) }. Any help would be great,thanks. My code is:
import random, matplotlib.pyplot as plt
def input():
arr=[]
ret_size=[]
ret_count=[]
n=int(input('enter the number of trials'))
for i in range(n):
x=int(input('size of array:'))
for z in range(x):
r=random.randint(1,2000)
arr.append(r)
count=0
for ind in range(1,len(arr)):
count+=1
cur=arr[ind]
count+=1
pos=ind
while pos>0 and arr[pos-1]>cur:
count+=1
pos=pos-1
count+=1
arr[pos]=cur
count+=1
print('sorted listL')
print(arr)
print('number of hops:')
print(count)
ret_size.append(x)
ret_count.append(count)
plt.plot(ret_size,ret_count)
plt.xlabel('size of input')
plt.ylabel('number of hops')
plt.title('insertion sort')
plt.show()
input()