🌐
W3Schools
w3schools.com › Python › python_ref_list.asp
Python List/Array Methods
Python has a set of built-in methods that you can use on lists/arrays.
🌐
GeeksforGeeks
geeksforgeeks.org › python › array-python-set-1-introduction-functions
Array Module in Python - GeeksforGeeks
August 2, 2025 - Example: It demonstrates to use insert() method to add an element at a specific position in an array.
Discussions

Array methods function in Python?
In Python, arrays are implemented using the array module, which provides a range of methods for working with arrays. More on mindstick.com
🌐 mindstick.com
0
July 4, 2018
Python arrays
If you're just learning, just use lists. They have essentially the same interface (meaning everything you can do to an array, you can do to a list), and while they are somewhat less performant, if you're just poking around, that's probably not important. If the performance is a consideration, use NumPy. If you want really fine control over exactly how memory is laid out, use a different language. More on reddit.com
🌐 r/learnpython
13
3
March 3, 2025
Declaring a python function with an array parameters and passing an array argument to the function call? - Stack Overflow
If the latter is what you wish I have found a method which works well. I'm more familiar with programming languages such as Fortran and C, in which you can define elemental functions which operate on each element inside an array. I finally tracked down the python equivalent to this and thought ... More on stackoverflow.com
🌐 stackoverflow.com
delegates - Calling functions by array index in Python - Stack Overflow
I have a bunch of functions in Python out1, out2, out3 etc. and would like to call them based on an integer I pass in. def arryofPointersToFns (value): #call outn where n = value Is there an... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Readthedocs
pythontutorial-wdyds.readthedocs.io › en › latest › 3_Lists_Arrays › lists_arrays.html
4. Lists and Arrays — A Python Tutorial for Data Scientists 2.0 documentation
For some data types, this will simply add a pair of square brackets around your data, but for other data types that you’ll eventually learn about, such as arrays, this type conversion can be more signficant. In particular, Python thinks of lists as collections of stuff so for some data types that can’t really be thought of that way, like a single integer or float, list() will throw a TypeError as you’ll see below.
🌐
Python
docs.python.org › 3 › library › array.html
array — Efficient arrays of numeric values
If given a bytes or bytearray object, the initializer is passed to the new array’s frombytes() method; if given a Unicode string, the initializer is passed to the fromunicode() method; otherwise, the initializer’s iterator is passed to the extend() method to add initial items to the array.
🌐
Mimo
mimo.org › glossary › python › arrays
Python Arrays: Syntax, Usage, and Examples
To create an array in Python, you can use either the built-in list type or the array module. Here's how both approaches look: ... This creates a list that behaves similarly to arrays in other languages. ... This method uses less memory but requires elements to be the same type.
🌐
W3Schools
w3schools.com › python › gloss_python_array_methods.asp
Python Array Methods
Python has a set of built-in methods that you can use on lists/arrays.
🌐
YouTube
youtube.com › watch
Array functions in Python | 28 - YouTube
In this video, we’ll dive deeper into advanced array functions in Python and explore how to manipulate and create arrays efficiently using inbuilt methods.We...
Published: October 30, 2025
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-arrays
Python Arrays - GeeksforGeeks
In order to search an element in the array we use index() method.
Published: 1 week ago
🌐
MindStick
mindstick.com › interview › 23453 › array-methods-function-in-python
Array methods function in Python? – MindStick
July 4, 2018 - In Python, arrays are implemented using the array module, which provides a range of methods for working with arrays.
🌐
Reddit
reddit.com › r/learnpython › python arrays
r/learnpython on Reddit: Python arrays
March 3, 2025 -

I'm following roadmap.sh/python to learn python. I'm at the DSA section.

I understand the concept of arrays in DSA, but what I don't understand is how to represent them in Python.

Some tutorials I've seen use lists to represent arrays (even though arrays are homogeneous and lists are heterogeneous).

I've seen some other tutorials use the arrays module to create arrays like array.array('i') where the array has only integers. But I have never seen anybody use this module to represent arrays.

I've also seen some tutorials use numpy arrays. Which I don't understand their difference from the normal arrays module.

What should I use to represent arrays?

So far I've solved a couple of arrays exercises using Python lists.

🌐
Medium
medium.com › @jvolpe721 › python-array-methods-414eb93a600a
Python- Array Methods. (some simple array methods- for… | by Jennifer Volpe | Medium
May 1, 2018 - Python’s list implementation of array allows us to delete any elements from an array using del operator. We can also use remove() and pop() methods to remove elements in an array.
🌐
New York University
physics.nyu.edu › pine › pymanual › html › chap3 › chap3_arrays.html
3. Strings, Lists, Arrays, and Dictionaries — PyMan 0.9.31 documentation
Therefore, we distinguish between array multiplication and matrix multiplication in Python. Normal matrix multiplication is done with NumPy’s dot function. For example, defining d to be the transpose of c using using the array function’s T transpose method creates an array with the correct ...
Top answer
1 of 5
57

tl;dr: Write an out(n) function rather than out1(), out2(), ..., outN() and don't bother with this hack.

I cannot imagine a reasonable scenario where this question would come up in practice. Please reconsider the architecture of the problem; there is likely to be a much better way to do this (because storing them in a list implies there is nothing meaningful about the functions except the index; for example, I can only imagine that you'd want to do this if you were creating a bunch of dynamically-generated thunks where their temporal ordering matters, or something similar). Especially any novice users you are reading this answer, consider making a more general function that can handle everything, or associating to each function some more identifying information, or sticking it as part of a class, etc.

That said, this is how you'd do it.

myFuncs = [f0,f1,f2]
myFuncs2 #calls f2

or

myFuncs = {'alice':f1, 'bob':f2}
myFuncs'alice' #calls f1

this is just the following two steps in one step:

myFuncs = [f0,f1,f2]
f = myFuncs[i]
f(...) #calls fi

or if you don't have a registry of functions 'myFunc' like the OP said above, you can use globals(), though it is extremely hackish form and to be avoided (unless you want those functions to be available in your module namespace, in which case maybe it's fine... but this is probably rarely the case, and you'd probably rather define those functions in a submodule then from mysubmodule import * them, which is in turn slightly frowned upon):

def fN(n):
    return globals()['f'+str(n)]

def f2():
    print("2 was called!")

fN(2)(...) #calls f2

here are two other ideas (added after answer was accepted and first two comments):

You can also create a decorator like this:

>>> def makeRegistrar():
...     registry = {}
...     def registrar(func):
...         registry[func.__name__] = func
...         return func  # normally a decorator returns a wrapped function, 
...                      # but here we return func unmodified, after registering it
...     registrar.all = registry
...     return registrar

and use it like so:

>>> reg = makeRegistrar()
>>> @reg
... def f1(a):
...  return a+1
... 
>>> @reg
... def f2(a,b):
...  return a+b
... 
>>> reg.all
{'f1': <function f1 at 0x7fc24c381958>, 'f2': <function f2 at 0x7fc24c3819e0>}

then you can call reg.all['f1']. You could adapt the reg decorator to keep track of the indexing and do something like:

registry = []
index = int(re.regextofindthenumber(func.__name__))
if not index==len(registry):
    raise Exception('Expected def f{} but got def f{}')
else:
    registry[index] = func

Alternatively, to avoid globals(), you could define a class:

class Funcs(object):
    def f1():
        ...
    def f2():
        ...
    def num(n):
        [code goes here]

If your number of functions is small, you could get away with ['f1','f2','f3'][i].

Of course without further information, all these suggestions are just ignoring the real problem: this situation should never come up, and is a possibly a sign of a serious architecture flaw, when you'd probably rather have something (to use your example) like:

# a possibly-better world
def out(n):
    # output to N, whatever that means

rather than

# what you have now
def out1():
    # output to 1
def out2():
    # output to 2
def outN(n):
    # ???
2 of 5
4

One can access methods through a dictionary:

def one1():
    print("Method one1 called")
def one2():
    print("Method one2 called")
def one3():
    print("Method one3 called")
methodDictionary = {1: one1, 2:one2, 3: one3}
method1 = methodDictionary[1]
method1()
method2 = methodDictionary[2]
method2()
method3 = methodDictionary[3]
method3()
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.array.html
numpy.array — NumPy v2.5 Manual
An array, any object exposing the array interface, an object whose __array__ method returns an array, or any (nested) sequence.
🌐
DevGenius
blog.devgenius.io › python-arrays-arrays-methods-a3ac1954ad8d
Python Arrays & Arrays Methods. Here In Python, the term “array” is… | by v_code | Dev Genius
October 25, 2023 - In Python, arrays are commonly represented using lists, and Python provides various methods to manipulate and work with lists
🌐
Medium
meganslo.medium.com › python-101-for-javascript-developers-part-ii-list-array-methods-edition-7064a5df6e07
Python 101 for JavaScript Developers (Part II — List/Array Methods Edition) | by Megan Lo | Medium
July 7, 2022 - There are a few methods that are quite mind-blowing [Look out for mind-blowing emoji 🤯]and I wish those also exist in JavaScript! ... I remembered when I was reading some JavaScript articles, append is a word that got thrown around a lot while that keyword doesn’t exist in JavaScript. Essentially, both append() and push() have very similar syntax, which you includes the element you want to push to the list/array inside the parenthesis. ... # Python my_list = ["python", "javascript", "c++"] my_list.append("ruby") print(my_list) # ["python", "javascript", "c++", "ruby"]// JavaScript const myList = ["python", "javascript", "c++"]; myList.push("ruby"); console.log(myList); // ["python", "javascript", "c++", "ruby"]
🌐
WsCube Tech
wscubetech.com › resources › python › arrays
Arrays in Python: Types, Syntax and Examples
August 6, 2026 - Master arrays in Python with easy examples. Learn types of arrays in Python, array methods, element access, insertion, common array operations & more. Read now.
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.7 documentation
December 6, 2023 - For instance, [None, 'hello', 10] doesn’t sort because integers can’t be compared to strings and None can’t be compared to other types. Also, there are some types that don’t have a defined ordering relation. For example, 3+4j < 5+7j isn’t a valid comparison. The list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (“last-in, first-out”).