-1

How do I partially make a string in Python? I am working on a for loop that appends a string over multiple reruns. Once a string is made it can't be changed. How do I make it so it is partially finished but the code will come back later and finish it?

  • 1
    Sure it can be changed... What's your example code that's not working? – pbuck Apr 20 '17 at 16:24
  • You either are not explaining your problem correctly or you have a misconception about assigning objects (including strings) to variables. It always helps to provide an example of what you are trying to do. https://stackoverflow.com/help/mcve – wwii Apr 20 '17 at 16:25
  • The string is immutable, so when you change it, python just makes a new string with your additions. What is the issue you are facing? – roganjosh Apr 20 '17 at 16:26
  • What are you really asking about? If you really feel the need to not concat in a for loop then just append items to a list and then join that list when you are done but in most cases using `+=` should be just fine. http://stackoverflow.com/questions/12169839/which-is-the-preferred-way-to-concatenate-a-string-in-python might help – scrappedcola Apr 20 '17 at 16:26

1 Answers1

1

You can append a string to another with the + operator

Code :

String = "start"
String = String + "end"
print String

Output :

"startend"
t.m.adam
  • 15,106
  • 3
  • 32
  • 52