开发者

Python Array Question(Programming)

开发者 https://www.devze.com 2023-03-25 17:32 出处:网络
What does the [] mean? Also how can I identify variables as empty arrays in python? 开发者_开发技巧Thanks!

What does the [] mean? Also how can I identify variables as empty arrays in python? 开发者_开发技巧Thanks!

perl: xcoords = ()

How do I translate that?


[] - is an empty list in Python and is the same as calling list() e.g. [] == list() To check that list is empty you can use len(l) or:

listV = [] # an empty list
if listV:
    # do something if list is not empty
else:
    # do something if list is really empty

To read more about list you can use the following link


Lists are like C++ arrays with some difference. One of difference is they can cary different types even lists. to check if lists is empty

lists = []
len(lists)
lists[0]= "More of me"
len(lists)

More check Python official tutorial and above Docs

0

精彩评论

暂无评论...
验证码 换一张
取 消