写一个python代码:1.查找元组中以a或A开头并且以c 结尾的所有元素。 tu = ("alec", " Aric", "Alex", "Tony", "rain")
时间: 2023-10-30 11:09:31 浏览: 88
用python一行代码得到数组中某个元素的个数方法
tu = ("alec", "Aric", "Alex", "Tony", "rain")
for i in tu:
ret = i.strip() # 删除字符串当前行首尾的的空格
if (ret.startswith('a') or ret.startswith('A')) and ret.endswith('c'):
print(ret) # 输出结果:alec Aric
阅读全文