0

I have an array of strings that I am trying to iterate through and store the string into another string. When I write this to another file, though, it comes out as %s.

Here is a snippet of the code:

for labels in rows[0]:
    if (labels == 'Year'):
        continue
    else:
        dataset = """{{\nlabel: '%s',\ndata: '%s',\nbackgroundColor: 'rgba(168, 191, 18, 0.7)',\nborderColor: 'rgba(168, 191, 18, 1)',\nborderWidth: 0\n}},\n""" % labels, labels
        f.write(dataset)
f.close()

Also, I was not sure how to split the dataset line into multiple lines while still keeping the formatting that it should. Can someone please help? Thank you!

1 Answer 1

1

Tried your code. It prints not enough arguments for format string. Try % (labels, labels)

Sign up to request clarification or add additional context in comments.

1 Comment

first labels is probably taken into account, and dataset is becoming an array => [ big string, labels ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.