Why is the d _1 = dict() not working?

Screen Link:

My Code:

faces = ['Jack', 'Queen', 'King', 'Ace']
suits = ['Clubs', 'Spades', 'Hearts', 'Diamonds']
numbers = [[ 1, 2, 3], [4, 5, 6, 7],[8 , 9, 10,]

d_1 = []

for i in range(len(faces)):
    d_1[numbers[i]] = dict(zip(cards,suits[i]))
    
print(d_1)

What I expected to happen:
a dictionary with cards

What actually happened:
d_1 = dict()
^
SyntaxError: invalid syntax

Replace this line with the output/error
1 Like

Please make sure that when you ask questions -

  1. Share the link to the Mission/Mission Step.
  2. Try to apply the appropriate tags to the question if possible.
  3. Make sure your code and the error you are pointing out match. The error points to d_1 = dict() which is not included in your shared code.

You can also refer to Introducing guidelines for all technical questions in our Community and Guide: How to Ask a Good Question as well.

1 Like

You left the [ open when numbers was defined.

Also, [] creates a list, not a dictionary. To create a dictionary you must use {}.

2 Likes