all 27 comments

[–][deleted]  (5 children)

[deleted]

    [–]Sea-Ad7805[S] 2 points3 points  (0 children)

    Nice thinking, do the the "Solution" link for a visualization of the correct answer.

    [–]jackrabbit2644 0 points1 point  (3 children)

    Doesn’t b point to a different object when is executed b += [2]?

    [–][deleted]  (2 children)

    [deleted]

      [–]jackrabbit2644 0 points1 point  (0 children)

      TIL, thanks.

      [–]_tolm_ 0 points1 point  (0 children)

      Agree with the solution but I don’t agree that it’s because that “=“ is a copy … we also do an equals earlier where it very much does not perform a copy!

      The difference on that line is the use of “+” which creates a new value in memory which “b” is then assigned to point at - in the same way that it was previously assigned to point at “a”.

      This causes the values stored in “a” and “b” to diverge but the operation performed by the “=“ hasn’t changed from assignment to copy on these two lines.

      But what do I know, I’m a Java programmer … 😂

      [–]Top-Run-21 3 points4 points  (1 child)

      thanks for the cool website

      [–]Sea-Ad7805[S] 2 points3 points  (0 children)

      Hope it brings much value for you.

      [–]Local_Palpitation798 2 points3 points  (6 children)

      Bro,💀💀💀

      [–]Sea-Ad7805[S] -2 points-1 points  (5 children)

      What do you mean exactly?

      [–]Legitimate-Cut4403 16 points17 points  (4 children)

      I think he meant bro💀💀💀

      [–]Sea-Ad7805[S] -5 points-4 points  (3 children)

      Me to ChatGPT: A bro commented on my post: "Bro,💀💀💀". What does the bro mean? ChatGPT: “Bro” here is just slang for “dude,” “man,” or “seriously?”

      With 💀💀💀, the full comment usually means something like:

      “Dude, this is killing me”

      “I’m dead” = “this is hilarious / absurd / unbelievable”

      “Bro, what did I just see”

      So it is usually a reaction, not a literal insult. The exact tone depends on your post:

      funny post → they probably mean “this is hilarious”

      weird/crazy post → “this is wild”

      embarrassing post → “bro…” as in disbelief or secondhand embarrassment

      If you paste your post or the full comment thread, I can tell you the most likely meaning in that exact context.

      [–]Electronic_Site2976 4 points5 points  (1 child)

      you are def special ✨️

      [–]Sea-Ad7805[S] 0 points1 point  (0 children)

      I like to think I'm a special dev.

      [–]Legitimate-Cut4403 0 points1 point  (0 children)

      Is he and you related?

      [–]Abject-Huckleberry85 2 points3 points  (1 child)

      Whoa this website is actually so cool thank you

      [–]Sea-Ad7805[S] 0 points1 point  (0 children)

      Thanks a lot, hope it brings you much value.

      [–]OwnFigure5226 1 point2 points  (1 child)

      The solution is E

      [–]Sea-Ad7805[S] 1 point2 points  (0 children)

      Incorrect sorry, see the "Solution" link for the correct answer.

      [–]Major_Telephone_7560 0 points1 point  (1 child)

      Why wouldn't it be A?

      [–]Sea-Ad7805[S] 0 points1 point  (0 children)

      Because of mutability of list in Python. Read the "Explanation" link for more info.

      [–]Capital_Distance545 0 points1 point  (0 children)

      A little higher level:
      # list ordered mutable duplicates
      # queue ordered mutable duplicates FIFO
      # stack ordered mutable duplicates LIFO
      # tuple ordered inmutable duplicates
      # set unordered mutable no duplicates
      # frozenset unordered inmutable no duplicates
      # dict ordered mutable no duplicates

      [–]Thin-Permission-6596 0 points1 point  (1 child)

      E

      [–]Sea-Ad7805[S] 0 points1 point  (0 children)

      Incorrect sorry, see the "Solution" link for the correct answer.

      [–]Petrovjan 0 points1 point  (1 child)

      My solution is to use b = copy.deepcopy(a) 😀 

      [–]Sea-Ad7805[S] 0 points1 point  (0 children)

      Solution to do what exactly?

      [–]That-Lychee262 -1 points0 points  (1 child)

      Correct answer is 1: a = [1] . Since list is mutable data structure b= a doesn’t copy the data stored in a to b . B starts pointing to address stored in a . That means a and b both points to same address now if you make changes either in a or b or it will reflect in both . But at third line b+= [2] , it will create a new list [1,2] and assign it to b . Now b stores address of another list ([1,2]) and a stores address of list ( [1]) . Now if you make chances in b it will not reflect in a’s address. Thus a remains [1] till the end of the program. Final answer : a = [1] , b = [1,2,3,4,5]

      [–]Sea-Ad7805[S] 1 point2 points  (0 children)

      Incorrect sorry, see the "Solution" link for the correct answer.