# Correct response variable not recognised for new experiment with new version: 'key\_resp.corr' always FALSE

**URL:** <https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654>\
**Category:** Builder\
**Created:** [February 22, 2021, 11:03am UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654 "2021-02-22T11:03:43Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 22, 2021, 11:03am UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/1 "2021-02-22T11:03:43Z")

</div>

**OS** (e.g. Win10): Win10  
**PsychoPy version** (e.g. 1.84.x): 2021.1.0  
**Standard Standalone? (y/n)** y  
**What are you trying to achieve?:** Assign correct keyboard response to variable in code component, have it recognised as “Correct answer” by subsequent keyboard component

**What did you try to make it work?:** Tried a simple new "experiment’’ with just 5 loops of trial, a code assigning one key as answer, and keyboard component after it, in order, with default allowable keyboard responses, one of which assigned as correct. Tried using ‘dollar sign’ and not using it ahead of variable name in “Correct answer” textbox of keyboard component dialog (apparently not needed anymore but tried it anyway). Tried “y” and “space” as correct assigned answer. But no response is recognised as correct. Data file shows “trial\_resp.corr” = 0 all the time. Tried opening an old experiment opened in this version of PsychoPy; it still works, with same correct answer logic (but the dialog box opens up differently, it doesn’t show the “$” sign ahead of the Correct answer box, but same version of PsychoPy). So just creating a new experiment seems to fail in this basic way.

No error message throughout any of this.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 22, 2021, 11:19am UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/2 "2021-02-22T11:19:41Z")

</div>

Please could you show a screenshots of your keyboard component and code component?

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 22, 2021, 11:38am UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/3 "2021-02-22T11:38:11Z")

</div>

just from dummy simple effort to check error in experiment being re-written in new version (because of old one no longer updating last-run file):  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/3/a/3a7d5daf6a4c3f4a303e5f939fee38c5deac7c55.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/d/bded465a8d0bd89ff7a4ba71ddb60713ceff646a.png)  
same line above given redundantly into “Begin Routine”. Various keys tried as answer other than space …  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/8/786dce2d7fbf6a9eb4099513a6bc9f2440073f37.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/d/6/d6b432b99a60c63d16ad211c2096d21b883ba642.png)  
also tried with ‘dollar sign’ ahead of ANSWER, and ‘last key’ not just first key.  
after pressing space all the time:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/c/ec73ee7608acd4e0ad33fefd54c5e2df823f45c1.png)  
This is from actual experiment where correct answer from code “RESPONSE\_EXP” is being added to data:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/4/4436ad91fa7fb29f5631c64fd5c75273e71f29aa.png)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 22, 2021, 1:07pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/4 "2021-02-22T13:07:37Z")

</div>

I’m not sure. I definitely have managed to use the correct answer field online.

Try  
ANSWER=[‘space’]  
just in case it wants a list instead of a string.

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 22, 2021, 1:24pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/5 "2021-02-22T13:24:33Z")

</div>

No, this doesn’t solve it. Haven’t tried online, using Psychopy. And yes, always used to work. Just doesn’t work for new experiment in this new version anymore

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 22, 2021, 1:44pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/6 "2021-02-22T13:44:53Z")

</div>

I’ve just noticed you’re using 2021

@TParsons might this be a new bug?

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [February 22, 2021, 1:48pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/7 "2021-02-22T13:48:36Z")

</div>

Could you upload the `psyexp` file? It could be a bug - possibly because Correct Answer for Keyboard is now validated as a list - but I’d need to have a look at the Python code from your experiment to make sure

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 22, 2021, 2:09pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/8 "2021-02-22T14:09:23Z")

</div>

ok, can’t load my whole experiment but here is the dummy bit just to check that the usual, simple assignment of correct response value to a variable for keyboard component to check if response correct works; it wouldn’t using this new version of PsychoPy, although it can handle it in the same way from old experiment. it seems to recognise the difference, even throws up a slightly different dialog for keyboard component if experiment written in older version. So this is just stripped back focus on the issue; you get a feedback bit too. You can see I’ve tried your list representation of the value, or you can go back to the single scalar value as before, which, again, still works from old experiment in this new version. it’s writing in new version that this doesn’t work anymore, one way or the other. maybe i’m doing something differently but just with these few settings … as always before …  
[dummy\_2.psyexp](https://discourse.psychopy.org/uploads/short-url/miLrFoU1YjmRsgxtlQMqvRqcy6q.psyexp) (11.1 KB)

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 22, 2021, 4:52pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/9 "2021-02-22T16:52:51Z")

</div>

tried also using [ANSWER] rather than just ANSWER or $ANSWER in the keyboard component’s “Correct answer” box, paired with the same or alternative form in the prior code giving a value to answer. Also tried running this new script, written and run within 2021.1.0 Builder, but switching version in settings to 2020.2.3, and it still doesn’t recognise the value; key\_resp.corr still always returns as 0.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 22, 2021, 4:55pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/10 "2021-02-22T16:55:57Z")

</div>

I doubt it’s the issue, but do try using corrAns instead of ANSWER just in case ANSWER’s a protected variable name.

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 22, 2021, 5:08pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/11 "2021-02-22T17:08:02Z")

</div>

nice try. No. Same thing. Always .corr = 0, always given 0 as its value whether key matches the key given to correct response variable or not. I was originally using “RESPONSE\_EXP” as name of variable in experiment when problem arose in rewriting the experiment from scratch, in this new version. Had worked in old version, written/saved in 2020.2.3, but that has stopped accepting any edits, updating “lastrun.py”, as raised in association with others elsewhere. That’s only reason why rewriting from scratch, otherwise worked before, Just this not working in new version now

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 23, 2021, 3:24am UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/12 "2021-02-23T03:24:47Z")

</div>

Another user seems to have found the same problem lately, more recently:

> [@Data from Correct Response won't show in Excel](https://discourse.psychopy.org/t/data-from-correct-response-wont-show-in-excel/20694):
>
> Hi there, I am having trouble with Psychopy marking whether or not a participant got the answer correct. In the Excel column (AG), all of the responses are 0 and do not show if the participant answered correctly. I have a practice loop and a trial loop. The system marks the practice correct (X) but not the trial. I have attached all my files and a screenshot of the problem in Excel. Thank you in advance for any help! In [frown] [LearningWord\_1.xlsx](https://discourse.psychopy.org/uploads/short-url/8GsF6t2Gm6KFldgN9QjXNkTqXaj.xlsx) (9.7 KB) [Practice.psyexp](https://discourse.psychopy.org/uploads/short-url/i95B2aMiUXPsy9AzC7dtmmdkW7o.psyexp) (30.4 KB)…

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 23, 2021, 3:31am UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/13 "2021-02-23T03:31:28Z")

</div>

Have tried uninstalling new version (2021), in which this was written, and reverting to 2020.3.10, but the psyexp file won’t run in that, nor will another experiment written in the new version; error is “opacity cannot = NoneType”; changed opacity to 1 in the text components, same error. Also the .py file isn’t generated from “Compile” in the new version; dialog pops up “… .py file not found”; and trying to do this in earlier version encounters multiple issues via “compile.py” or similar. Won’t raise as separate issues as can’t investigate exhaustively at this stage. Just noting that here in case you want to run the .psyexp file attached above and check it out.

---

<div class="post-metadata">

**Author:** ![rvgart](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rvgart](https://discourse.psychopy.org/u/rvgart)\
**Post date:** [February 23, 2021, 12:20pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/14 "2021-02-23T12:20:28Z")

</div>

What did you find by running the psyexp you asked me to upload for you? Did you confirm the issue or found an error on my part? Or could you not run the file? Or what else? Please advise…

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [February 23, 2021, 3:01pm UTC](https://discourse.psychopy.org/t/correct-response-variable-not-recognised-for-new-experiment-with-new-version-key-resp-corr-always-false/20654/15 "2021-02-23T15:01:53Z")

</div>

Ah I’ve found the problem - it’s the new param types in `2021.1`. Essentially, it sees whatever you give a Keyboard for it’s correct answer as a list, not a string. This is only a problem for experiments made in `2021.1.0` - experiments made earlier will have the old param types and so will be interpreted fine. I’ll fix this in `2021.1.1`, but for your specific experiment I’m afraid you’ll have to do a bit of manual substitution - you could either remake the Keyboard components again in the next version, or open the `.psyexp` in notepad (or equivalent program) and replace anything like this:

```auto
<Param name="correctAns" val="space" valType="list" updates="constant"/>

```

with this:

```auto
<Param name="correctAns" val="space" valType="str" updates="constant"/>

```

(`val` might differ between components, but the rest should stay the same, so you can use CTRL to find them all quickly)

Sorry for the inconvenience! It’s something I missed when refactoring.
