Home > Enterprise >  Pass Array of values to a string text
Pass Array of values to a string text

Time:10-08

Im trying to pass a list of string values to append to the end of a text description. However when I pass the array it is only appending the last value in the array to description text I want

'''

with open("text.csv", 'r') as csv3:
                import3 = csv3.readlines()
                #for row in import3:
                self.log_text(import3) // contains multiple rows of data 

   def log_text(self, row):

 
            k = 0
            row = len(row)
         
            for k in range(0, row, 1):
                description = "The following features can no longer be accessed on: \n %s"  % (row[k])

'''

This prints the last value in the CSV file but it contains multiple values how to I add all values to the description?

CodePudding user response:

You can use "join" to concatenate a list of strings without using for loop:

def log_text(row):
        description = "The following features can no longer be accessed on: \n %s"  % (' '.join(row))
        return description
  • Related