2069/adding-elements-to-a-list-in-python
I have a list like this:
[5, 7, 12, 13, 24, 32]
I want to add two more elements to the list. I tried append() but that gave me a syntax error. How do I do this?
Use extend() instead:
l = [5, 7, 12, 13, 24, 32] l.append([1,2]) print(l)
This should give you
[5, 7, 12, 13, 24, 32, 1, 2]
To initialize an empty list do this: new_list ...READ MORE
ou are using Python 2.x syntax with ...READ MORE
You can use the reversed function in ...READ MORE
Not sure what your desired output is, ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
Here's a generator that yields the chunks ...READ MORE
To count the number of appearances: from collections ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.