Python学习

本文通过一个具体的Python列表操作示例,介绍了如何使用Python的基本列表方法,包括添加元素、删除元素等,并展示了如何遍历列表。这是一篇适合初学者了解Python列表基本用法的文章。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Python——List(1)

Python学习这里只加上例子

cast=["a",1,"b",2,"c",3,"d",4]
print len(cast)
cast.append("e")
print len(cast)
print cast
cast.extend(["f","g"])
print cast
cast.remove("a")
print cast
cast.insert(0,"z")
print cast
for i in cast:
	print(i)
cnt=0				#attention the origin
while cnt<len(cast):#attention the operator ':'!!!
	print(cast[cnt])
	cnt = cnt+1
#python don't have the check for the check-error
#so ,the check for cast[100] will get a mistake


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值