0

This is the data I am working on:

bank_details = {
    "bank_details_top_level" : 
    ("""
        {"name":"Shyam"},
        {"password":"thisissecret"},
        {"account_id":"93847518"}  
        """),
}

I want to pass in the account_id value, i.e., 93847518 as a variable but since it is inside a string, I decided to use string formatting. However, because I am already using {} inside, I keep getting errors.

Is there any way I can pass in data into this string?

  • Above code works fine. I don't see any syntactical errors. However, why not create it as nested dict instead of string formatting. Like this: `bank_details = {"bank_details_top_level": {"name":"Shyam", "password": "thisissecret", "account_id": "93847518" }}` – Moinuddin Quadri Jan 03 '21 at 08:02
  • Use `{{` instead of `{` in your data. Or use the `%` interpolation operator. – BoarGules Jan 03 '21 at 08:03

0 Answers0