Q. How String can be concatenate in Python ? Is there any functions like C and C++ ?
Ans.
First see how concatenation in C:
C programming having strcat() for string concatenations.
See the example:
void main()
{
char str1[MAX],str2[MAX];
printf(“Input string 1: “);
gets(str1);
printf(“nInput string 2: “);
gets(str2);
printf(“nConcatenated string : “);
puts(str1);
return 0;
}
Concatenation in C++:
‘+’ operator can be used for string concatenation.
See the example:
void main()
{
string firstName = “Kunal “;
string lastName = “Batra”;
string fullName = firstName + lastName;
cout << fullName;
}
‘Append()’ can also be used for string concatenation:
See the example:
void main()
{
string firstName = “Kunal”;
string lastName = “Batra”;
string fullName = firstName.append(lastName);
cout << fullName;
}
Concatenation in Python:
‘+’ operator is used for string concatenation:
firstName = “Kunal”
lalstName = “Batra”
fullName = firstName + lastName
print(fullName)
From above article its easy to find out the answer of the question.