+ 1
What's the "+" for?
i'm trying to remove the "+" symbol to combine string, the output is the same. whats the "+" function in the examples mean?
3 Answers
+ 3
Literal strings are automatically concatenated by the interpreter:
print('hello' 'world')
However, you need to use + to concatenate variables:
a = 'hello'
b = 'world'
print(a + b)
0
ah, i see it now. thanks all :D
0
only same kind of variables can be concatenated
for instance say
>>>print('helloworld' + '2')
would give you an error because both are not of same type
but instead
>>>print('helloworld'+str(2)) would work perfectly since both of same type .