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

Click to Enlarge


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

Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250