Dec-31-2018, 07:06 AM
(This post was last modified: Dec-31-2018, 07:07 AM by Gribouillis.)
I think the problem is that the contents of the
Color_Names
variable is inconsistent at different parts of the file. If Color_Names' value is the list ['Red', 'Green', 'Blue', 'Yellow']
, then calling random.choice(Color_Names)
returns one of these colors, such as 'Blue'
. But at the end of askcolornames()
, you return Color_Names[0]
, which would be 'Red'
in our case. If Color_Names is the single word 'Red', the call random.choice(Color_Names)
will return a random letter from the word 'Red'. This random letter could be 'e'
. So you need to be consistent in the use of this variable, make sure that Color_Names is always a list of strings and not a single string.