Seymore4Head <Seymore4Head@Hotmail.invalid> writes: > I want to toggle between color="Red" and color="Blue"
It's good to cultivate ongoing familiarity with the standard library <URL:https://docs.python.org/3/library/itertools.html#itertools.cycle> so that you can make use of wheels already invented and maintained:: import itertools colours = ["Red", "Blue"] colour_cycle = itertools.cycle(colours) next(colour_cycle) # → "Red" next(colour_cycle) # → "Blue" next(colour_cycle) # → "Red" next(colour_cycle) # → "Blue" next(colour_cycle) # → "Red" for colour in colour_cycle: # … loops indefinitely # with ‘colour’ bound to each value in turn … -- \ “My roommate got a pet elephant. Then it got lost. It's in the | `\ apartment somewhere.” —Steven Wright | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list