+ 6

In js if we add strings and number then result is displayed where as in python it displays error.why its output is different?

is it because of string operations are different in different languages. "string"+20+" string2" displays different output in js and python

23rd Dec 2017, 4:23 PM
Priyanka
Priyanka - avatar
2 Answers
+ 6
That is because Python doesn't (or can't) implicitly convert objects from one type to another. A solution is to convert your int into string and then add them! print(str(2) + "35") https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
23rd Dec 2017, 4:39 PM
Dev
Dev - avatar
+ 3
thank you
23rd Dec 2017, 6:23 PM
Nishant Srivastav
Nishant Srivastav - avatar