0
Why did we use + sign there
3 Réponses
+ 1
ifi, you are right. There are many ways. But now we discuss about "+". There are many cases where "+" will be the best choise. For example you have 2 strings: x and y. And you should print it once with spece between. The simplest way is: print(x+" "+y). You can do it with join and format. But they are more powerful and complicated ways.
0
When concatinate strings? It is simplest way of doing that. What do you suggest to change to?
- 1
there are different ways of concatenate strings, using + is one of them
others are
string formatting ( eg with % or {} operators as paceholder)
or using the join method
there is no 'right' or 'wrong' method. it mainly depends on your style or what is best for code readability at the time.
http://www.pythonforbeginners.com/concatenation/string-concatenation-and-formatting-in-JUMP_LINK__&&__python__&&__JUMP_LINK