S
Scott
As said before I'm new to programming, and I need in depth explaination to
understand everything the way I want to know it, call it a personality quirk
;p.
With pop() you remove the last element of a list and return its value:
Now I know list is a bad name, but for the sake of arguement lets assume its
not a built in sequence>
I understand all that. What I don't understand is why all the documentation
I see says, "When removing a specific element from a list using pop() it
must be in this format: list.pop().
At first I took that to mean that list.pop(i) would return some type of
error, but it doesn't.
I can't find any documentation saying that this rule that I keep reading
about (again list.pop() ) is the only format to use when removing a
specific element because......with the explaination to follow.
Now I'm not stupid enough to believe that I'm the first to try:
'is'['this', 'an', 'example']
I guess simplistically all I'm asking is: Is this just a community agreed
upon rule for readability purposes? or Is it a rule that's in place for a
reason I'll learn later on? Please keep in mind my intro sentence to this
post. I would like a very detailed explaination, or at least a link to a
very detailed expression. ONLY....of course....if the explaination isn't,
well it just is because we all agreed to use it that way. That explaination
I'll understand and except, but with a bit of dissatisfaction.
understand everything the way I want to know it, call it a personality quirk
;p.
With pop() you remove the last element of a list and return its value:
Now I know list is a bad name, but for the sake of arguement lets assume its
not a built in sequence>
['this', 'is', 'an']list = ['this', 'is', 'an', 'example']
list.pop() 'example'
list
I understand all that. What I don't understand is why all the documentation
I see says, "When removing a specific element from a list using pop() it
must be in this format: list.pop().
At first I took that to mean that list.pop(i) would return some type of
error, but it doesn't.
I can't find any documentation saying that this rule that I keep reading
about (again list.pop() ) is the only format to use when removing a
specific element because......with the explaination to follow.
Now I'm not stupid enough to believe that I'm the first to try:
and have it return the desired effect of:list = ['this', 'is', 'an', 'example']
list.pop(1)
'is'['this', 'an', 'example']
I guess simplistically all I'm asking is: Is this just a community agreed
upon rule for readability purposes? or Is it a rule that's in place for a
reason I'll learn later on? Please keep in mind my intro sentence to this
post. I would like a very detailed explaination, or at least a link to a
very detailed expression. ONLY....of course....if the explaination isn't,
well it just is because we all agreed to use it that way. That explaination
I'll understand and except, but with a bit of dissatisfaction.