FAQ: Learn Python – Lists and Functions – Using an element from a list in a function

This community-built FAQ covers the “Using an element from a list in a function” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise Using an Element from a List in a Function:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

What is an element? This hasn’t been defined in the course as far as I know - is it an item in a list?

1 Like

A list is a sequence of objects, separated by commas, the whole enclosed within brackets. The objects can be identified within the list by location within the sequence, specified by an integer called an index. The first index is always zero.

► The objects can be, and often are, referred to as elements of the list; as you note, they are likewise referred to as items in the list.

So if my_list = ['a', 'b', 'c']

The elements are the strings ‘a’, ‘b’ and ‘c’

… and the element, for example, at index 1 is ‘b’

1 Like

Thanks - the terminology is really confusing. I’d appreciate if you know a resource or webpage I can read because I’m very confused…

(So items can be strings, are they also variables? Are arguments variables? If those things in dictionaries are keys, are the values attached to them also arguments?)

1 Like

almost any group of symbols can be a variable (there are a few restrictions - a variable can’t begin with a number, for instance), and when the Python interpreter sees a sequence of symbols not surrounded by quotes, and not a known keyword such as def, it will assume that is a variable. If the variable has never been assigned a value, then an error will be raised:

a
print(a)

'''Output
Traceback (most recent call last):
  File "C:\path\to\test.py", line 1, in <module>
    a
NameError: name 'a' is not defined
'''
a = 7
print(a)

'''Output
7
'''

If the symbol is surrounded by single or double quotes, it will be interpreted as a string.

2 Likes

An argument is a value that you tell a function to put inside of its parentheses when it runs.

print(max(10, 7))
''' Output:
10
'''

max(10, 7) is the argument to print(), and 10 and 7 are the arguments to max()

1 Like

So the variable is a, not 7! Got you.

And arguments only assign to functions. Ok - that makes more sense now, thank you!

2 Likes

ffghgfjkgkytu :smiley: :stuck_out_tongue_winking_eye: :stuck_out_tongue_winking_eye:

Hey all , i have one query,
while i am using .pop(index) function inside the function arguments,

then how is it changing the parameter n

Argument is used everywhere in this topic.
In the chapter about functions we learned about arguments and parameters:

Not using the correct terminology only makes it more confusing.
I think this topic needs an update.
“items” here is a parameter not an argument
“numbers” is passed into the function as an argument