lowercase list py code example

Example 1: how to lowercase list in python

[x.lower() for x in ["A","B","C"]]
['a', 'b', 'c']

>>> [x.upper() for x in ["a","b","c"]]
['A', 'B', 'C']

>>> map(lambda x:x.lower(),["A","B","C"])
['a', 'b', 'c']
>>> map(lambda x:x.upper(),["a","b","c"])
['A', 'B', 'C']

Example 2: Write a method that converts all strings in a list to their upper case lambda

import java.util.Arrays;
import java.util.List;
//www .  jav a 2 s  .  c o  m
public class Main {

  public static void main(final String[] args) {
    List<String> friends = Arrays.asList("Ross", "Chandler", "CSS",
        "Monica", "Joey", "Rachel");

    friends.stream().map(name -> name.toUpperCase())
        .forEach(name -> System.out.print(name + " "));

  }

}

Tags:

Java Example