+ 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?

26th Jan 2017, 10:48 PM
arif mafazan simohartono
arif mafazan simohartono - avatar
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)
27th Jan 2017, 2:41 AM
Igor B
Igor B - avatar
0
ah, i see it now. thanks all :D
28th Jan 2017, 12:51 PM
arif mafazan simohartono
arif mafazan simohartono - avatar
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 .
4th Feb 2017, 12:12 PM
Shivam Bhatt