how to use concatenate a fixed string and a variable in Python how to use concatenate a fixed string and a variable in Python python python

how to use concatenate a fixed string and a variable in Python


I'm guessing that you meant to do this:

msg['Subject'] = "Auto Hella Restart Report " + sys.argv[1]# To concatenate strings in python, use       ^ 


variable=" Hello..."  print (variable)  print("This is the Test File "+variable)  

for integer type ...

variable="  10"  print (variable)  print("This is the Test File "+str(variable))  


I know this is a little old but I wanted to add an updated answer with f-strings which were introduced in Python version 3.6:

msg['Subject'] = f'Auto Hella Restart Report {sys.argv[1]}'