In Python 2.7.1, I'm trying to provide a list of messages as the first argument, and a list of colors as the second argument. I want the second argument to default to a list of whites if it's not provided. This is the way I tried to do it:
def multicolor_message(msgs, colors=[libtcod.white for x in len(msgs)]):
#function body
libtcod.white is a part of the library I'm using and is in no way causing any problems.
The compiler says the variable msgs
is not defined. Obviously the msgs
variable doesn't exist in this scope, but I need to create a list of appropriate length and assign it to colors
. What is the cleanest way to do this?