#concatination """concatenation is used to add two string by "+" operator. If you forgot to add something in yoyr string U cant rechange it because string are immutable but u can add another string in it.""" a = "karan learning" print(a) #want to add more in a ,no promble use concatenation. b= a +" "+ "python" print(b) #mutiplication # used to multiply string number of times print("karan") print("___+_+___" *3) print("singh") c= ("Hello ") print(c*4)
@nikharsachdeva9 ай бұрын
del keyword deletes reference to string not the string object from memory itself str1 = "codeyug" str2 = str1 Now we have a string object "codeyug" with two references to it str1 and str2 If you print id(str1) and id(str2). It will print same id. Means both names are refering to same string object del str1 It will delete reference "str1" but string object is still there as it is also referred by str2 print(str2) will print codeyug del str2 Now str2 reference is deleted. and since no reference/name is pointed to string "codeyug" now the string object will be collected by garbage collector hence deleted