menu

Questions & Answers

I'm new and do not understand how this code works. Can someone please help me understand how this is working?

I don't understand how all this works together. I'm confused on all the symbol names. I know the symbol_count is the dictionary. I know the all_symbols is the list. Then we have symbol, where did this come from? There is also symbols.items(). I just need a walk through of this code and how it is working a step at a time.

symbol_count = {
  "A": 2,
  "B": 4,
  "C": 6,
  "D": 8
}

def get_slot_machine_spin(rows, cols, symbols):
  all_symbols = []
  for symbol, symbol_count in symbols.items():
    for _ in range(symbol_count):
      all_symbols.append(symbol)
Comments:
2023-01-25 00:30:08
I suggest reading docs.python.org/3/library/typing.html , as well as the other docs over the .items() function of dict types
Answers(0) :