0

Python concatenation question

Brand new to coding, 3 days in and noticed that printing strings without a + or , will result in the same output (except for the space placed by ,) Is it just good practice to throw a concatenation in there to make it easier to read and is it ok to omit them completely? Example: print(“python” + “question”) print(“python” “question”) Both output pythonquestion

29th Jan 2022, 9:48 AM
Jay Safo
Jay Safo - avatar
2 Answers
+ 2
I tried it with some code, the one that is commented out isn't working. x = "python" + str(5) + "question" print("python" + str(5) + "question") #print("python" str(5) "question") print(x) y = "python" "question" print(y) And there is something like good practice. I use the +.
29th Jan 2022, 10:03 AM
Paul
Paul - avatar
+ 1
Thank You, someone on reddit called it an implicit concatenation and it only with string literals. Variables return and error. So kind of only works with very basic code
29th Jan 2022, 10:10 AM
Jay Safo
Jay Safo - avatar