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,890 points

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
• 13,210 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
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,720 points
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,930 points
+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 412 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
• 13,210 points
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
• 13,210 points