i write this code to sort the element of an array but iam getting this error line 9, in if(a[i]>a[j]): IndexError: list index out of range the same logic for sorting array elements work with java or c correctly. help me to find why this is happening in python . is this due to python syntax or another
from array import *
a=[]
n=int(input("enter number of elements:"))
for i in range(0,n):
b=input("enter element")
a.append(b)
for i in range(0,n):
for j in range(i+1,n):
if(a[i]>a[j]):
temp=a[i]
a[i]=a[j]
a[j]=temp
print("sorted")
for i in range(0,n-1):
print(a[i])
print(a[n-1])