Difference between using plus (+) and comma (,) in print()

Hello!

While working on the physics project I wondered what’s the difference between these two ways of printing different data types, in this case string+int or float. Which one is better and why?

print("The GE train supplies " +  str(train_force) + " Newtons of force.")
print("The GE train supplies", train_force, "Newtons of force.")

I only discovered that when using comma there is no need to add extra spaces and to convert the int to str.

The physic project’s url: https://www.codecademy.com/paths/computer-science/tracks/cspath-intro/modules/cspath-python-functions/projects/physics-class

+ for strings is concatenation
when providing arguments to a function, separate the arguments with comma
add(1, 3)

3 Likes