智者不为愚者谋,勇者不为怯者死。这篇文章主要讲述python获取列表长度相关的知识,希望能为你提供帮助。
Get list length in python 3 | Examples |
len() function | list = [10, 20, 30] n = len(list) print(“The length of list is: “, n) |
for loop | list = [‘Python’,’java’,’Kotlin’,’Machine Learning’,’Keras’] size = 0 print(“Length of the input string:”) for x in list: size+=1 print(size) |
len() function for nested list | nestedList = [‘Krishna’, 20,’John’, [20, 40, 50, 65, 22], ‘Yung’, 11.98] 【python获取列表长度】print(“Original List = “, nestedList) print(“Length of a Nested List = “, len(nestedList[3])) |
推荐阅读
- Proxmox VE 7.0升级到Proxmox VE 7.1虚拟机重启失败
- 运维小白成长记——第五周
- XML DOM 节点树概述
- k8s-apiServer鉴权
- ubuntu20.04启用SSH
- docker搭建docker私服仓库nexus
- Docker 安装zabbix 5
- ubuntu20.04更换阿里的软件源
- Linux之kill命令