Given a list of strings, write a Python program to convert case of all string from lowercase/uppercase to uppercase/lowercase.
Input :
['PrO', 'pROG', 'RAMmInG']
Output:
['pro', 'prog', 'ramming']
Input :
['fun', 'Foo', 'BaR']
Output:
['FUN', 'FOO', 'BAR']
Method #1 : Convert Uppercase to Lowercase using map function
out = map(lambda x:x.lower(), [ 'PrO', 'pROG', 'RAMmInG']) output = list(out) print(output)
Output:
['pro', 'prog', 'ramming']
Method #2: Convert Lowercase to Uppercase using List comprehension
input = ['fun', 'Foo', 'BaR'] lst = [x.upper() for x in input] print(lst)
Output:
['FUN', 'FOO', 'BAR']