Challenge 46 - Generating 2D Dictionaries

Question: I used the following code to generate my MokiDex but the “MokeDex[name]= MokeBeast” line is overwriting the stats for all Mokebeasts i.e. it takes the latest MokeBeast dictionary and assigns it to all name keys rather than the latest name key. Can somebody please explain why this is happening?


Repl link:

MokeDex = {}
MokeBeast = {"type":None, "specialmove":None, "startingHP":None,"startingMP":None}

while True:
  name = input("Input your beast's name >")
  for key in MokeBeast.keys():
    MokeBeast[key] = input(f"Input your beast's {key} >")

  #print(MokeBeast)
  MokeDex[name]= MokeBeast
  #print(MokeDex)
  check = input("Do you want to add another beast? y/n>")
  if check == "n":
    break

A post was merged into an existing topic: Day 046 - Project 46 : MokéBeasts Mokédex