answer please
Demonstrate how to create simple and multi-line strings, and check whether a string can change after its creation.
(python program)
1 Answer
You can write multi-mile strings by using "\n" character.
Example:
a = "Hello\nWorld!"
print(a)
This outputs:
Hello
Wordl!
You can also construct multi-line strings by using " character three times ("""), as such:
a = """Helllo
World"""
print(a)
This also outputs:
Hello
Wordl!
However, I do not what do you mean by your second question: check whether a string can change after its creation[?]
All variables in Python, to my knowledge, can be changed. There are no constants (unless, you're willing to go through some trouble to implement them: https://stackoverflow.com/questions/2682745/how-do-i-create-a-constant-in-python)
For example:
a = "Hello"
print(a)
a = "World!"
print(a)
This outputs:
Hello
World!
Also, a tip, your question title should be more precise, since it gives the people who want to help no information on your problem, as an exmaple this question's title could be something like Multi-line strings and how to check string mutability in Python. Even better you could split your post into two seperate ones (Multi-line strings in Python and How to check string mutability in Python), since in essence these are different questions, unless I failed to see a connection, then you should clarify in your question how these two issues are connected. Another thing, you should specify which programming language you are using in the title.