Snippets tagged “lists”
6 snippets use this tag.
- How can I get the concatenation of two lists in Python without modifying either one?Python
There are a few different ways to concatenate two lists in Python without modifying either one.
- How can I make a dictionary (dict) from separate lists of keys and values?Python
You can use the zip function to create a dictionary from separate lists of keys and values like this:
- How can I turn a List of Lists into a List in Java 8?Java
You can use the flatMap method from the Stream API to turn a List<List<T>> (a list of lists) into a List<T> in Java 8. Here's an example of how you can do this:
- How do I check if a list is empty?Python
To check if a list is empty in Python, you can use an if statement and the len() function.
- How do I pass a variable by reference?Python
In Python, you can pass a variable by reference by using the & operator.
- What's the difference between lists and tuples?Python
Lists and tuples are both used to store multiple items in a single variable, but they are different in a few key ways.