0

Why did we use + sign there

17th Dec 2017, 8:00 AM
Manoj Sharma
Manoj Sharma - avatar
3 Answers
+ 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.
17th Dec 2017, 10:45 AM
Aleksey Borovkov
Aleksey Borovkov - avatar
0
When concatinate strings? It is simplest way of doing that. What do you suggest to change to?
17th Dec 2017, 9:59 AM
Aleksey Borovkov
Aleksey Borovkov - avatar
- 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
17th Dec 2017, 10:29 AM
ifl
ifl - avatar