Here is the error it gives me:
TypeError: 'int' object is not iterable
Here is my code:
Expand|Select|Wrap|Line Numbers
- 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)