I am learning Python on top of the Java, so I am having confusion in string concatenation functionality offered by Python. In Python, if you concatenate both string and number using simple plus(+) operator, it will throw you the error. However the same thing in Java prints the correct output and either concatenate the string and number or adds up them.
Why Python is not supporting the concatenation of both string and number in the same manner as Java.
- Is there any hidden advantage of that?
- How we can achieve the concatenation thing in Python
####################In Java########################33
System.out.println(10+15+"hello"+30) will give output 25hello30
System.out.println("hello"+10+15) will give output hello1015
#########In Python#########################
print(10+15+"hello"+30) will give error: unsupported operand type(s) for
+: 'int' and 'str'
print("hello"+10+15) can ony concatenate str(not "int") to str