How does [:] work in python?

0 votes
The [:] is used to copy a list usually. But in the following code :

x = x[:]

how can both copies be called the same thing?
Jul 2 by ana1504.k
• 7,470 points
16 views

1 answer to this question.

0 votes
The right is evaluated first, placed into a temporary variable, and x is re-assigned to the temp variable. You never see it, of course.
answered Jul 2 by SDeb
• 12,360 points

Related Questions

+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 131 views
0 votes
1 answer

How does insertion work in Python?

Or, this one: def ins_sort(k): ...READ MORE

answered Oct 8, 2018 in Python by charlie_brown
• 7,710 points
21 views
0 votes
1 answer

How does % work in Python?

The % (modulo) operator yields the remainder ...READ MORE

answered Oct 10, 2018 in Python by SDeb
• 12,360 points
16 views
0 votes
1 answer

How does slice notation in Python work?

The Python tutorial talks about it (scroll down a ...READ MORE

answered Oct 31, 2018 in Python by Priyaj
• 56,160 points
28 views
0 votes
0 answers

How does function definition work in python?

Is it same as other programming languages ...READ MORE

Jun 13 in Python by Waseem
• 3,480 points
9 views
0 votes
0 answers

How does pillow work in opening and closing images in python?

Is there a separate library that we ...READ MORE

4 days ago in Python by Waseem
• 3,480 points
10 views
+1 vote
1 answer

How does a blockchain work in hyperledger framework?

Hyperledger Composer simplifies application development on top ...READ MORE

answered Apr 19, 2018 in Blockchain by Christine
• 15,790 points
90 views