#原始列表
nums=[5,12,7,9,21,7,14]
#统计数字7出现的次数
count_seven=nums.count(7)
print("数字7出现的次数:",count_seven)
#判断99是否存在, 不存在则添加
if 99 not in nums:
	nums.append(99)
print("添加99后的列表:",nums)
#删除第一次出现的数字7
nums.remove(7)   #只删除第一个7
print("删除第一个7后的列表:",nums)
#取出第2个到第4个元素(索引1到3)
sub_list=nums[1:4]
print("第2~4个元素组成的列表:",sub_list)
msg = "hello 123 WORLD"
#统计长度和小写字母个数
length = len(msg)
lower_count = sum(1 for ch in msg if ch. islower())
print("长度:",length)
print("小写字母个数:",lower_count)
#替换并转小写
new_msg = msg.replace("WORLD","Python")
result = new_msg.lower()
print("结果:",result)