NO.1
#!/usr/bin/env python3 # -*- coding:utf-8 -*- L1 = ['Hello','World',18,'Apple',None] L2 = [x.lower() for x in L1 if isinstance(x,str)] print(L2)
NO.2
#!/usr/bin/env python3 # -*- coding:utf-8 -*- L1 = ['Hello','World',18,'Apple',None] L2 = [] for x in L1: if isinstance(x,str): L2.append(x.lower()) else: continue print(L2)
python3 homework.py
['Hello','World','Apple']
Sign in to make a reply
LingByron
NO.1
NO.2
python3 homework.py