Pop() ,remove() and insert() use instances

Hey Guys,

just a few questions here on pop and remove.

  1. .pop, vs. remove, which does what? when should they be used? which is used more in advanced code?
  2. can pop and insert be used on 2 dimensional lists?

thankyou in advance, any input on the matter is much appreciated

They are list methods. A good place to always check is the documentation. There are use case examples there:

Try them out and see what happens.

okie dokie, will have a look, thanks man

alright, i think i get it. But what does it mean by returning? what exactly does returning the data mean?
I have read multiple articles about returning but the language is always to advanced for me to understand. so i would appreciate if you could give a real simple answer. thankyou

It’s going to be confusing at times (you’re not alone in that). In the beginning, the lexicon seems so out of reach almost; like it’s a secret that everyone else but you knows. One spends a LOT of time googling what terms mean (everyone does this; that’s how we learn, right? Right).

In the most basic sense, the return statement does just that: it returns something from a function–whether it be a value (like a number/integer, or float), or it can be an object (list, dictionary, a tuple, another function) when you call the function. You can only use a return statement inside a function or method. Otherwise you’ll get an error. (See below).

def cat(name):   #defining the function. it takes one parameter, cat
    return "This is my cat, " + name   #return this when we call the function

cat("George")   #you're calling the function, "cat" and passing the name/argument George thru it. 

>>This is my cat, George

return "This is my cat " + name

>>File "<ipython-input-17-dc74106e388c>", line 1
    return "This is my cat " + name
SyntaxError: 'return' outside function

Keep reading the articles from various sources (including documentation which can be confusing). It will sink in. It just takes time and repetition/practice.

yeah your absolutely right. its pretty confusing, i got a book on all the python syntax, keywords functions and whatnot. when i first read it, i felt like i was trying to decipher some ancient egyptian writing or something. i keep going over it as i learn more and some parts slowly start to come into focus and i realise its just english lol.

another question I have though;
what is the difference between keywords and built in functions?
for example:
return and append.

they both seem like keywords to me but what exactly is there difference?
sorry to just ask all these questions, i do appreciate your taking time out to answer.
but at the same time you will probably see lots more of me around on the forum. So I apologise and thankyou in advance for your patience

1 Like

No worries. You’re on the right track.

You could start a new topic/thread—because this one has kind of strayed from the original topic—with your latest questions. If you have code examples you can post it too (formatted & including any error messages.)

alright no worries, thanks for the help, much appreciated

1 Like