{"id":3527,"date":"2022-12-01T19:47:32","date_gmt":"2022-12-01T19:47:32","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=3527"},"modified":"2022-12-01T19:47:33","modified_gmt":"2022-12-01T19:47:33","slug":"python-string-concatenation","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/python-string-concatenation\/","title":{"rendered":"Python String Concatenation"},"content":{"rendered":"<p style=\"text-align: center;\">String Concatenation<\/p>\n<p>When we use the + operator with the numbers, we are just performing the addition. For example, 5 + 6 is 11. But what if we are using the same + operator with the strings? Well, this would be something called string concatenation. This simply means that we are joining the two strings. If we are doing &#8216;Hello&#8217; + &#8216;GyaniPandit&#8217;, it would be &#8216;HelloGyaniPandit&#8217;. Let\u2019s have a look at a program, which demonstrates string concatenation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3528 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/STRING-CONCATENATION.jpg\" alt=\"\" width=\"646\" height=\"57\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/STRING-CONCATENATION.jpg 646w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/STRING-CONCATENATION-300x26.jpg 300w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/p>\n<h2 style=\"text-align: center;\">Python String Concatenation<\/h2>\n<p>As you can see, we have two strings in the program, and in the later instruction, we are concatenating them. As stated earlier, concatenation means joining the two strings. If you try to run the above program, you will simply see the two strings being concatenated, which simply means that the output should be simply &#8216;HelloGyaniPandit&#8217;.<\/p>\n<p>You can assign that concatenated string to some variable if in case we are required to use the value later in the program. Have a look at the below program, which explains the same thing.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3529 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/STRING-CONCATENATION-1.jpg\" alt=\"\" width=\"642\" height=\"103\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/STRING-CONCATENATION-1.jpg 642w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/STRING-CONCATENATION-1-300x48.jpg 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/p>\n<p>As you can see, the concatenated string is being assigned to another variable, and in case we are required to use that concatenated string later in the program, we can simply use it. If you run the above program, there would be no change in the output, but we have assigned that concatenated string to another variable. You can further try concatenating more strings and observe the outputs accordingly. Also, we would perform string concatenation as and when needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>String Concatenation When we use the + operator with the numbers, we are just performing the addition. For example, 5 + 6 is 11. But what if we are using the same + operator with the strings? Well, this would be something called string concatenation. This simply means that we are joining the two strings. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[26,27],"class_list":{"0":"post-3527","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python-tutorial","7":"tag-python","8":"tag-python-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=3527"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3527\/revisions"}],"predecessor-version":[{"id":4160,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3527\/revisions\/4160"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=3527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=3527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=3527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}