Skip to main content
Post Closed as "Duplicate" by Martijn Pieters python
deleted 68 characters in body
Source Link

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v): n += v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

**[1[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]**6] 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

**[1[1, 2, 3, 4, 5, 6] [1, 2, 3]**3] 

Using the += has a different result with the fully expanded operation. What is causing this?

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v): n += v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

**[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]** 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

**[1, 2, 3, 4, 5, 6] [1, 2, 3]** 

Using the += has a different result with the fully expanded operation. What is causing this?

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v): n += v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6] 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1, 2, 3, 4, 5, 6] [1, 2, 3] 

Using the += has a different result with the fully expanded operation. What is causing this?

deleted 68 characters in body
Source Link

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v): n += v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1**[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]6]** 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1**[1, 2, 3, 4, 5, 6] [1, 2, 3]3]** 

Using the += has a different result with the fully expanded operation. What is causing this?

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v): n += v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6] 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1, 2, 3, 4, 5, 6] [1, 2, 3] 

Using the += has a different result with the fully expanded operation. What is causing this?

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v): n += v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

**[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]** 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

**[1, 2, 3, 4, 5, 6] [1, 2, 3]** 

Using the += has a different result with the fully expanded operation. What is causing this?

formatting
Source Link
Danila Ganchar
  • 11.5k
  • 13
  • 69
  • 102

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v):

def assign_value(n, v):  n += v  print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1)

The output will be: [1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]

[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6] 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1)

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be: [1, 2, 3, 4, 5, 6] [1, 2, 3]

[1, 2, 3, 4, 5, 6] [1, 2, 3] 

Using the += has a different result with the fully expanded operation. What is causing this?

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v):

n += v print(n) 

l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1)

The output will be: [1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1)

The output will be: [1, 2, 3, 4, 5, 6] [1, 2, 3]

Using the += has a different result with the fully expanded operation. What is causing this?

I had learned that n = n + v and n += v are the same. Until this;

def assign_value(n, v):  n += v  print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6] 

Now when I use the expanded version:

def assign_value(n, v): n = n + v print(n) l1 = [1, 2, 3] l2 = [4, 5, 6] assign_value(l1, l2) print(l1) 

The output will be:

[1, 2, 3, 4, 5, 6] [1, 2, 3] 

Using the += has a different result with the fully expanded operation. What is causing this?

added 1 character in body
Source Link
Loading
deleted 3 characters in body
Source Link
Loading
fixing code format
Source Link
Loading
Source Link
Loading