Articles → Python → Concatenate String In Python

Concatenate String In Python






Syntax


“string 1” + “string 2”





Example




welcome = "Welcome"
firstname = "Karan"
lastname ="gupta"


fullmessage = welcome +" " + firstname + " "+ lastname

print (fullmessage)




Picture showing how the strings are concatenated in python using the + operator



Concatenating Substring




welcome = "Welcome"
firstname = "Karan"
lastname ="gupta"


fullmessage = welcome[0:1] +" " + firstname[0:1] + " "+ lastname[0:1]

print (fullmessage)




Picture showing how the substrings are concatenated in python



Posted By  -  Karan Gupta
 
Posted On  -  Friday, February 1, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250