+ 3
Help to slove this error in python 😞😥
A undefined error in this program class insertion: def algo(self,n,elems): for i in range(1,int(n)): j = i while j>=1: if elems[j] < elems[j-1]: temp = elems[j] elems[j] = elems[j-1] elems[j-1] = temp j = j - 1 print('sorted list',elems) def inps(self): elems = [] n = input('enter no of elements : ') for i in range(int(n)): elems.append(int(input())) print('entered list',elems) algo(n,elems) i = insertion() i.inps() i.algorithm()
5 Réponses
+ 9
use "self.algo(n, elems)" and remove last line
+ 8
Because you didn't remove last line
+ 4
Mert Yazıcı it giving typeError
https://code.sololearn.com/c1PB5Egqjxqd/?ref=app
+ 4
Sololearn takes all inputs at one time so you need to separate your inputs with enter button. Your input should be something like this
4
4
2
3
1
or
2
1
2
https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
+ 1
Mert Yazıcı thanks...😊