+ 4
How Python adds two strings without using +operator?
For eg. >>>"Hello" "world" If you do this. Then output will be "Hello world"
13 ответов
+ 2
From the link I sent since you probably didn't bother to read it:
"Multiple adjacent string literals (delimited by whitespace), possibly using different quoting conventions, are allowed, and their meaning is the same as their concatenation. Thus, "hello" 'world' is equivalent to "helloworld". This feature can be used to reduce the number of backslashes needed, to split long strings conveniently across long lines, or even to add comments to parts of strings, for example:
re.compile("[A-Za-z_]" # letter or underscore
"[A-Za-z0-9_]*" # letter, digit or underscore
)
Note that this feature is defined at the syntactical level, but implemented at compile time. The ‘+’ operator must be used to concatenate string expressions at run time. Also note that literal concatenation can use different quoting styles for each component (even mixing raw strings and triple quoted strings)."
+ 7
s = [ "Happy", "SoloLearning", ";)" ]
separator = " "
x = separator.join(s)
print(x)
# x = "Happy SoloLearning ;)"
+ 3
https://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation
+ 3
There's a string method:
"".join(["Tom", "ate", "toe"]) -> "Tomatetoe"
+ 3
+ 2
I think I have answered all the possible ways of doing it .
+ 2
I still have doubt that without + operator how these strings get concatenate 🤔
namrata garg Sonic
+ 2
Perhaps in Python, adjacent strings get concatenated.
+ 2
This is what the question is.. "how"😂.
This means we don't require + in python
+ 1
Faisal Reza [Indian] there is no + operator
+ 1
If you want to print "HELLO" " WORLD"
You can simply use - print("HELLO WORLD")
or
if you want to print "I" "live" "in" "Delhi"
then simply write all the words in between " " like print (" I live in Delhi")
BUT if you have printed hello already and now you want to add world or your name with it ,then you can concatenate the strings i.e. join them by
M1-
Print("hello"+"world")
or
M2-
str1=" hello"
str2= "world"
print(str1+str2)
+ 1
namrata garg I believe they are commenting about the ability to concatenate without using +.
0
Use only "" with another one