Post

Earnest Codes
Earnest Codes@Earnesto037·
@Python_Dv Answer: Different Here's the logic; s = "Python": A string object "Python" is created in memory, and s points to it. t = s: The variable t is assigned to the same object as s. At this point, both s and t share the same memory address. if s is t:: The is operator checks for
English
1
0
4
434
Jimmy Fikes
Jimmy Fikes@akajim·
@Python_Dv "Different" will print. Initially, t is s (both pointing to the same string object). In the first if statement, since s is t, '3' is concatenated to 'Python' making s point to 'Python3' a new object in memory. Now, since s is not t, "Different" is printed.
English
0
0
1
231
Tomasz Alemao
Tomasz Alemao@TomMarAlem1987·
@Python_Dv Strings are immutable. Once changed it no longer resembles the initial string. Hence Different.
English
0
0
1
242
Alex
Alex@alex_dev_1994·
@Python_Dv My take: is checks identity, == checks value.
English
0
0
1
230
Biel Men
Biel Men@BielMenHaha·
@Python_Dv Different At some point the var "s" will create another str instance at some another memory address, not refering to the "t" memory address anymore.
English
0
0
0
79
Paylaş