MattClarke
0
Q:

python merge strings

df["period"] = df["Year"].astype(str) + df["quarter"]
1
# 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
# 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 
1
print “{0} {1} is {2} years old.” format(fname, lname, age)
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