Python array not working

后端 未结 4 590
暗喜
暗喜 2021-01-22 09:40

This is so simple! Why isnt it working?!?!?

My python program...

def main():
    mont = []
    mont[0] = \"bnkj1\"
    mont[1] = \"bnkj2\"
    mont[2] =          


        
4条回答
  •  心在旅途
    2021-01-22 10:35

    This avoids building an empty list and then appending to it thrice.

    def main():
        mont = ["bnkj1", "bnkj2", "bnkj3"]
        print(mont[0])
    
    main()
    

提交回复
热议问题