Q:

combine two strings python

str1 = “Hello”
str2 = “World”
str1 + str2
8
# initializing string  
test_string = "GFG"
  
# initializing add_string 
add_string = " is best"
  
# printing original string  
print("The original string : " + str(test_string)) 
  
# printing original add string  
print("The add string : " + str(add_string)) 
  
# Using += operator 
# adding one string to another  
test_string += add_string 
4
print “{0} {1} is {2} years old.” format(fname, lname, age)
1
x = ‘apples’
y = ‘lemons’
z = “In the basket are %s and %s” % (x,y)
1
my_list = ['a', 'b', 'c', 'd']
my_string = ','.join(my_list)
# Output = 'a,b,c,d'
1
>>> 'a' + 'b' + 'c'
'abc'
0
>>> orig_string = 'Hello'
>>> orig_string + ', world'
'Hello, world'
>>> orig_string
'Hello'
>>> full_sentence = orig_string + ', world'
>>> full_sentence
'Hello, world'
0

New to Communities?

Join the community