Returns a list of the contents of the specified length

Requirements: examining incoming length of the list, if more than 2, only the first two reserved content length, content and returns the new

DEF len_two (List1):
     Print ( ' content of the input is: ' , List1)
     IF len (List1)> 2 :
        list2 = list1[:2:]
    else:
        List2 = List1
     Print ( ' content output is: ' , List2)


len_two([1])
len_two([1,[1,2],3])

 

Guess you like

Origin www.cnblogs.com/kite123/p/11653768.html