查找列表中的元素,移动空格 并查找以a或A 为开头 并以c 结尾的元素

li = ['alec',' aric','Alex','Tony','rain']
tu = ('alec',' aric','Alex','Tony','rain')
dic = {
'k1':'alec',
'k2':' aric',
'k3':'Alex',
'k4':'rain',
}

for li1 in li:
li1_new = li1.strip().capitalize()
if li1_new.startswith('A') and li1_new.endswith('c'):
print(li1_new)

for tu1 in tu:
tu1_new = tu1.strip().capitalize()
if tu1_new.startswith('A') and tu1_new.endswith('c'):
print(tu1_new)

for dic_v in dic.values():
dic1_new = dic_v.strip().capitalize()
if dic1_new.startswith('A') and dic1_new.endswith('c'):
print(dic1_new)
posted @ 2017-11-06 12:44  口水哥  阅读(978)  评论(0编辑  收藏  举报