What does [:] mean?

0 votes
I have been working on a Python code. Can someone explain me the meaning of [:] in the following:

pop = population[:]
 

Is it something like array lists in Java or like a bi-dimensional array?
Jan 16 in Python by ana1504.k
• 7,430 points
11 views

1 answer to this question.

0 votes
It's a slicing, and what it does depends on the type of population. If population is a list, this line will create a copy of the list. For an object of type tuple or a str, it will do nothing (the line will do the same without [:]), and for a NumPy array, it will create a new view to the same data.
answered Jan 16 by SDeb
• 12,280 points

Related Questions In Python

+4 votes
3 answers

What does these operator mean **, ^, %, // ?

** - Performs exponential (power) calculation on ...READ MORE

answered Apr 11, 2018 in Python by anto.trigg4
• 3,420 points
31 views
0 votes
1 answer

What does ' -> ' mean in Python function definitions?

It's a function annotation. In more detail, Python 2.x ...READ MORE

answered May 22, 2018 in Python by charlie_brown
• 7,710 points
38 views
0 votes
1 answer

What does AF_INET mean?

AF_INET refers to Address from the Internet ...READ MORE

answered Jul 3 in Python by Wajiha
• 1,120 points
7 views
+1 vote
3 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 128 views
0 votes
1 answer

What does enumerate mean?

The enumerate() function adds a counter to ...READ MORE

answered Oct 11, 2018 in Python by SDeb
• 12,280 points
14 views
0 votes
1 answer

What does the return statement do in Python?

The print() function is use to write ...READ MORE

answered Oct 1, 2018 in Python by SDeb
• 12,280 points
46 views