Could you please help me find the error. I myself have (i might be wrong) boiled it down to the for loop because it somehow magically converts a list into an int and tries to iterate over that. But I don't know how to fix it, doesn't even make sense why it would do it. Please help me out. Thanks in advance!
Here is the error it gives me:
TypeError: 'int' object is not iterable
Here is my code:
Here is the error it gives me:
TypeError: 'int' object is not iterable
Here is my code:
Code:
import random
unsortedlist = range(0,10)
random.shuffle(unsortedlist)
print unsortedlist
def quickSort(ML):
if ML == []:
return []
else:
rdex = random.randint(0, (len(ML)-1)) # chose a random index for pivot
p = ML[rdex] # get the actual pivot integer
LL, GL = [],[]
if len(ML) == 1:
return ML
else:
del ML[rdex]
for i in ML:
if i < p:
LL.append(i)
else:
GL.append(i)
return quickSort(LL) + list(p) + quickSort(GL)
if __name__ == '__main__':
print quickSort(unsortedlist)
Comment