Why some Python variables stay global, while some require definition as global
问题 I'm having a bit of trouble understanding why some variables are local and some are global. E.g. when I try this: from random import randint score = 0 choice_index_map = {"a": 0, "b": 1, "c": 2, "d": 3} questions = [ "What is the answer for this sample question?", "Answers where 1 is a, 2 is b, etc.", "Another sample question; answer is d." ] choices = [ ["a) choice 1", "b) choice 2", "c) choice 3", "d) choice 4"], ["a) choice 1", "b) choice 2", "c) choice 3", "d) choice 4"], ["a) choice 1",