+ 1

List comprehension for swapcase

Any idea on how to write a fucntion using list comprehension which has similar properties as swapcase?

19th Mar 2018, 7:17 PM
Lee Yao Dong
Lee Yao Dong - avatar
3 Réponses
+ 8
s='AbcDefG' print(*[i.upper() if i.islower() else i.lower() for i in s],sep='')
19th Mar 2018, 7:43 PM
Louis
Louis - avatar