0 votes
in Python Flask by
How to add values to a python array?

1 Answer

0 votes
by

In python, adding elements in an array can be easily done with the help of extend(),append() and insert() functions.

Consider the following example:

x=arr.array('d', [11.1 , 2.1 ,3.1] )

x.append(10.1)

print(x)   #[11.1,2.1,3.1,10.1]

x.extend([8.3,1.3,5.3])

print(x)  #[11.1,2.1,3.1,10.1,8.3,1.3,5.3]

x.insert(2,6.2)

print(x)        # [11.1,2.1,6.2,3.1,10.1,8.3,1.3,5.3]

Related questions

0 votes
asked May 9, 2023 in Python Flask by Robin
+1 vote
asked Aug 24, 2020 in MongoDB by Hodge
...