0
What changes?
Whatâs the difference if you write: print(âhello â + âworldâ) and: print(âhello worldâ) ?
2 Answers
+ 3
You're doing an extra operation in:
print("hello " + "world")
That operation is called string concatenation, and it consumes more time than simple do:
print( "hello world"). But, with the first one, you can be more dynamic.
Example:
name = "Antonio"
print("Hello " + name)
String concatenation is not very efficient because strings are immutable, so string concatenation needs to allocate more memory to store the new string with the ones you're concatenating, there are other ways to do the same thing which are more efficient.
0
Thanks