May 13th, 2013, 04:19 PM
Join Date: Mar 2013
Time spent in forums: 1 h 43 m 55 sec
Reputation Power: 0
Adding and deleting elements within lists at the same time
How does one add to a list while deleting from a list in one string? For example, here's a rundown of the different commands I understand.
## Create a simple list
inventory = ["notebook", "pencils", "textbooks"]
## Splice the list to give you "['notebook', 'pencils']"
## Add "calculator" to the list
inventory += ["calculator"]
## Reassign an index
inventory = "notepad"
## Delete an element
## delete a slice
## Add an element, while deleting a different element at the same time
I'm just wondering if it were possible, using either well-placed commas or concatenating, to multitask and reduce the number of lines. Also, I noticed that URLs are not allowed. How about using pastebin?