Concatenarea a doua stringuri
# Declaring two strings string1 = "Hello" string2 = "world" # Concatenating the strings result = string1 + " " + string2 # Printing the concatenated string print(result)
Lungimea unui string
# Declaring a string my_string = "Hello World" # Finding the length of the string length = len(my_string) # Printing the length of the string print("Length of the string:", length)
Inlocuirea unui substring:
# Declaring a string my_string = "Hello World" # Replacing a substring result = my_string.replace("World", "Universe") # Printing the resulting string print(result)