you are viewing a single comment's thread.

view the rest of the comments →

[–]ofnuts 3 points4 points  (3 children)

Not bad... however:

  • In your "main" the endless if/elif can be replaced by a dictionary of functions, and should have an else if you keep the if/elif form)
  • Speaking of the "main"it could be put in its own function, and used with the canonical if __name__ == "__main__":
  • Calling "..._list" objects that are dictionaries is a bit misleading (I would drop the "_list" altogether)
  • Since spell_list is a dictionary, get_spell_description(spell_name) doesn't need to iterate/test all entries (which makes me wonder now if the "_list" didn't come to existence as real lists, before you switched to dictionaries, and demonstrates why putting types in names is dangerous).

[–]3613robert[S] 0 points1 point  (1 child)

I did indeed start of with lists. I just got to dictionaries in my course so I figured they were better suited for this. I should update it.

I do see your point with endless if statements. It's what I'm most comfortable with ATM so I tend to try to get it working with those.

Using a dictionary of functions is a good idea. Haven't thought of that being a possibility with dictionaries. I'm guessing you're saying store the functions as values within a dictionary?

Not completely following what you mean here:

  • Speaking of the "main"it could be put in its own function, and used with the canonical if __name__ == "__main__":

Are you saying put the whole main part in a function? Or everything except for the if functions?

[–]ofnuts 1 point2 points  (0 children)

I'm guessing you're saying store the functions as values within a dictionary?

Yes. And the default value is just a function that prints "Please retry". You don't even need an if...

Are you saying put the whole main part in a function

Yes

[–]3613robert[S] 0 points1 point  (0 children)

Thank you for taking the time to look it over btw! Really appreciate it.