World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
If I want to add a character or number to an existing string after randomly creating it, how can I add a character to a string?
You can add a character to an existing string by using the concatenation operator "+". Here is an example:
my_string = "Hello" new_char = " World!" my_string = my_string + new_char print(my_string)
Output:
Hello World!
In this example, the "+" operator is used to concatenate the original string "Hello" with the new string " World!" and store the result back into the variable "my_string".