I’m analyzing some Python code and I don’t know what
pop = population[:]
means. Is it something like array lists in Java or like a bi-dimensional array?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is an example of slice notation, and what it does depends on the type of
population. Ifpopulationis a list, this line will create a shallow copy of the list. For an object of typetupleor astr, it will do nothing (the line will do the same without[:]), and for a (say) NumPy array, it will create a new view to the same data.