0

I have a list which should contain string with a particular format or character i.e. {{str(x), str(y)},{str(x), str(y)}}. I tried to do string concat like: "{{"+str(x), str(y)+"},{"+str(x), str(y)+"}}" and append to list, but it gets surrounded by brackets: [({{str(x), str(y)}),({str(x), str(y)}})] How can I get rid of the brackets or betterstill, is there a better approach to having a list without brackets like this: [{{string, string},{string, string}}]

1
  • Those braces; you heard about sets? Commented Sep 20, 2016 at 14:39

1 Answer 1

1

The parentheses are because you're creating a tuple of three items:

  • "{{"+str(x)
  • str(y)+"},{"+str(x)
  • str(y)+"}}"

Try replacing those bare commas between str(x) and str(y) with +","+:

"{{"+str(x)+","+str(y)+"},{"+str(x)+","str(y)+"}}"
Sign up to request clarification or add additional context in comments.

Comments

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.