List Methods: Example
List Methods: Example
Example
Use the format() method to insert numbers into strings:
age = 36
txt = "My name is John, and I am {}"
print(txt.format(age))
List Methods
Python has a set of built-in methods that you can use on lists.
Method Description
extend() Add the elements of a list (or any iterable), to the end of the current l
index() Returns the index of the first element with the specified value
insert() Adds an element at the specified position
Set Methods
Python has a set of built-in methods that you can use on sets.
Method Description
other sets
or not
or not
or not
others
Dictionary Methods
Python has a set of built-in methods that you can use on dictionaries.
Method Description
items() Returns a list containing the a tuple for each key value pair
setdefault() Returns the value of the specified key. If the key does not exist: in