String concatenation in python

This recipe explains how to perform string concatenation in python

Concatenation of strings in python

In python, To concatenate (or join) two or more string, we use '+' operator. To concatenate given string for a given number of time, we use '*' operator.

Lets understand with a few examples

 

    str1='Hello'
    str2='World !!'

    #to concatenate without spaces
    print('concatenate without space--',str1+str2)
    
    #to concatenate with spaces
    print('concatenate with space--',str1+' '+str2)

    #concatenate multiple times
    print('concatenate a given string multiple times--',str1*3)

 

Output

 

    concatenate without space--HelloWorld !!
    concatenate with space--Hello World !!
    concatenate a given string multiple times--HelloHelloHello

There are loads of other ways in which we can concatenate strings. Check out the tutorial for Format function in python to know about much more amazing ways of string concatenation.


Download Materials


What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

MLOps AWS Project on Topic Modeling using Gunicorn Flask
In this project we will see the end-to-end machine learning development process to design, build and manage reproducible, testable, and evolvable machine learning models by using AWS

Build an AI Insurance Agent for Eligibility Analysis Using CrewAI
Build an AI Insurance Agent that automates eligibility checks by extracting medical details, mapping conditions to policy terms, and generating explainable coverage decisions using CrewAI and LLMs. This is an upcoming project that is expected to be launched in June.

Build a Customer Churn Prediction Model using Decision Trees
Develop a customer churn prediction model using decision tree machine learning algorithms and data science on streaming service data.

Mastering A/B Testing: A Practical Guide for Production
In this A/B Testing for Machine Learning Project, you will gain hands-on experience in conducting A/B tests, analyzing statistical significance, and understanding the challenges of building a solution for A/B testing in a production environment.

FEAST Feature Store Example for Scaling Machine Learning
FEAST Feature Store Example- Learn to use FEAST Feature Store to manage, store, and discover features for customer churn prediction machine learning project.

Loan Default Prediction Project using Explainable AI ML Models
Loan Default Prediction Project that employs sophisticated machine learning models, such as XGBoost and Random Forest and delves deep into the realm of Explainable AI, ensuring every prediction is transparent and understandable.

Recommender System Machine Learning Project for Beginners-2
Recommender System Machine Learning Project for Beginners Part 2- Learn how to build a recommender system for market basket analysis using association rule mining.

PyTorch Project to Build a LSTM Text Classification Model
In this PyTorch Project you will learn how to build an LSTM Text Classification model for Classifying the Reviews of an App .

MLOps Project to Build Search Relevancy Algorithm with SBERT
In this MLOps SBERT project you will learn to build and deploy an accurate and scalable search algorithm on AWS using SBERT and ANNOY to enhance search relevancy in news articles.

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

OSZAR »