在python中'else'语句的INVALID SYNTAX ERROR

0 python if-statement syntax-error

我正在尝试在python中编写一个quicksort程序,但是我在invalid syntax error at else statement下面的第二行中得到了一个:

import random

n=int(raw_input("Enter the size of the list: ")) # size of the list
intlist = [0]*n
for num in range(n):
    intlist[num]=random.randint(0,10*n)

pivot=random.choice(intlist)
list_1=[] # list of elements smaller than pivot
list_2=[] # list of elements greater than pivot

for num in range(n):
    if num<=pivot:
        list_1.append(num)
    else
        list_2.append(num)
Run Code Online (Sandbox Code Playgroud)

这还不是一个完整的程序,因为我还在写作.

aar*_*ing 5

else它之后添加一个冒号,使它看起来像else:.并拿起一个很好的教程;)