Top "List" questions

The list tag may refer to: a linked list (an ordered set of nodes, each referencing its successor), or a form of dynamic array.

Writing a list to a file with Python

Is this the cleanest way to write a list to a file, since writelines() doesn't insert newline characters? file.writelines(["%…

python file list file-io newline
Removing duplicates in the lists

Pretty much I need to write a program that checks if a list has any duplicates and if it does …

python algorithm list duplicates intersection
How can I reverse a list in Python?

How can I do the following in Python? array = [0, 10, 20, 40] for (i = array.length() - 1; i >= 0; i--) I need to …

python list
Create an empty list in python with certain size

I want to create an empty list (or whatever is the best way) that can hold 10 elements. After that I …

python list
How to randomly select an item from a list?

Assume I have the following list: foo = ['a', 'b', 'c', 'd', 'e'] What is the simplest way to retrieve an …

python list random
How to initialize List<String> object in Java?

I can not initialize a List as in the following code: List<String> supplierNames = new List<String&…

java list
Converting array to list in Java

How do I convert an array to a list in Java? I used the Arrays.asList() but the behavior (and …

java arrays list data-conversion
How to Sort a List<T> by a property in the object

I have a class called Order which has properties such as OrderId, OrderDate, Quantity, and Total. I have a list …

c# generics list sorting
Why is it string.join(list) instead of list.join(string)?

This has always confused me. It seems like this would be nicer: my_list = ["Hello", "world"] print(my_list.join("…

python string list
How to return dictionary keys as a list in Python?

In Python 2.7, I could get dictionary keys, values, or items as a list: >>> newdict = {1:0, 2:0, 3:0} >>> …

python python-3.x list dictionary python-2.x