[URGENT] ValueError: could not convert string to float: 'blue'

OS: Win10
PsychoPy version: v2021.1.2
**Standard Standalone?:y
**What are you trying to achieve?: All I’m trying to do is get the code to randomize text colour for each randomized word

**What did you try to make it work?: I tried a lot – $WordColour, $WordColour($cur_colour), I tried putting WordColour = [‘blue’,‘red’] because I’m only using blue and red

What specifically went wrong when you tried that?:
Traceback (most recent call last):
File “C:\Users\Cooco\Desktop\CO_productioneffects_test_lastrun.py”, line 1806, in
mctext.setColor(WordColour, colorSpace=‘rgb’)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\basevisual.py”, line 514, in setColor
self.setForeColor(color, colorSpace=colorSpace, operation=operation, log=log)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\basevisual.py”, line 503, in setForeColor
self.foreColor = color
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\basevisual.py”, line 353, in foreColor
self._foreColor = Color(value, self.colorSpace)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\colors.py”, line 245, in init
self.set(color=color, space=space)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\colors.py”, line 334, in set
color, space = self.validate(color, space)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\colors.py”, line 291, in validate
self.alpha = color[:, 1]
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\colors.py”, line 440, in alpha
value = float(value)
ValueError: could not convert string to float: ‘blue’

Sometimes it would say could not convert string to float: ‘red’ but whatever I put into the excel sheet doesn’t change it either, hex codes don’t work and rgb codes don’t work either :frowning:

It looks like the colour is being set to a list containing blue and red rather than being set to either blue or red - so it thinks you’re specifying a named colour “red” accompanied by an alpha value of “blue”. Are you putting each different colour in its own row on the Excel sheet, or both in the same cell?

I put 1 colour per cell. The error always switches between blue and red so I’m unsure.

How are you putting red and blue in your Excel file? Just the text?

How are you setting the colour of the word? Is it just by putting a $ followed by the Excel column title?

I randomise colours of Stroop stimuli in code, for which I use variables set to different colours (to facilitate it working online)

For example in Begin Experiment
colours =[[red,’left”],[blue,”right”]]

Then in Begin Routine

The actual code I use is slightly more involved but hopefully this gets across the gist