str.format() raises KeyError str.format() raises KeyError python python

str.format() raises KeyError


The problem is those { and } characters you have there that don't specify a key for formatting. You need to double them up, so change your code to:

addr_list_formatted.append("""    "{0}"    {{    "gamedir"  "str"    "address"  "{1}"    }}""".format(addr_list_idx, addr))