Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

list in python

# Creating a List
grocery_list = ["apple", "watermelon", "chocolate"]

# Appending items to a list
grocery_list.append("milk")

# Changing an item on the list
grocery_list[1] = "apple juice"

# Deleting an item on the list
grocery_list.remove("watermelon")

# Sort list in alphabetical order
grocery_list.sort()

# Joining lists
utensils = ["fork", "spoon", "steak knife"]
list = grocery_list + utensils

# Printing the lists
print(*list, sep=", ")
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #list #python
ADD COMMENT
Topic
Name
8+8 =