Question: I am reading the [Python documentation on fancier output formatting](https://docs.python.org/3/tutorial/inputoutput.html) and they have example code which is confusing. In the following code:

```
table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}

print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; Dcab: {0[Dcab]:d}'.format(table))

Jack: 4098; Sjoerd: 4127; Dcab: 8637678

```

What does the `0` refer to in `{0[Jack]:d}` and `{0[Sjoerd]:d}`. The tutorial's explanation **omits** any hint about the function of those zeros.
[This video tutorial about formatting strings uses the same syntax without explaining it clearly too!](https://youtu.be/8HySMSRpeDw?t=385)

If I put a `1` in the place of `0` I get the error:

```
IndexError: tuple index out of range

```

What on Earth has the `tuple` have to do with it?

***Taken from the Documentation:***

> 
> If you have a really long format string that you don’t want to split
>  up, it would be nice if you could reference the variables to be
>  formatted by name instead of by position. This can be done by simply
>  passing the dict and using square brackets '[]' to access the keys
> 
> 
>

Answer: 
The `0` is the index of the `format` argument, i.e. `table` in this case. 

It doesn't work with `1` because there's only one argument, that's what "tuple index out of range" is saying.

The documentation does mention this [here](https://docs.python.org/3/tutorial/inputoutput.html#the-string-format-method):

> 
> A number in the brackets can be used to refer to the position of the object passed into the str.format() method.
> 
> 
>
You can just use:

```
table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
print('Jack: {Jack}; Sjoerd: {Sjoerd}; Dcab: {Dcab}'.format(**table))

```