Python : What is the purpose of a colon in an if statement?

后端 未结 4 1807
暗喜
暗喜 2021-01-29 17:21

I have this piece of python code below.

def m(list):
    v = list[0]
    for e in list:
        if v < e:
            v = e
        return v

values = [[3, 4,         


        
4条回答
  •  借酒劲吻你
    2021-01-29 17:26

    It's called a colon in english, not a double colon or double comma.

    I urge you to read a basic Python introduction.

    if v < e: v = e
    

    Is the same as:

    if v < e:
        v = e
    

提交回复
热议问题