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.

Finding the index of an item in a list

Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index (1) in …

python list indexing
How do I get the number of elements in a list?

Consider the following: items = [] items.append("apple") items.append("orange") items.append("banana") # FAKE METHOD: items.amount() # Should return 3 How …

python list
How do I check if a list is empty?

For example, if passed the following: a = [] How do I check to see if a is empty?

python list
How do I concatenate two lists in Python?

How do I concatenate two lists in Python? Example: listone = [1, 2, 3] listtwo = [4, 5, 6] Expected outcome: >>> joinedlist [1, 2, 3, 4, 5, 6]

python list concatenation
How to remove an element from a list by index

How do I remove an element from a list by index in Python? I found the list.remove method, but …

python list
How to convert list to string

How can I convert a list to a string using Python?

python string list
How to make a flat list out of list of lists?

I wonder whether there is a shortcut to make a simple list out of list of lists in Python. I …

python list multidimensional-array flatten
Getting the last element of a list

In Python, how do you get the last element of a list?

python list indexing
Accessing the index in 'for' loops?

How do I access the index in a for loop like the following? ints = [8, 23, 45, 12, 78] for i in ints: print('item #{} = {}…

python loops list