# TypeError '\>' not supported between instances of 'list' and 'float' (feedback only after 1.5s)

**URL:** <https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968>\
**Category:** Builder\
**Created:** [December 14, 2020, 12:15pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968 "2020-12-14T12:15:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![hannah1](https://avatars.discourse-cdn.com/v4/letter/h/ed655f/32.png) [@hannah1](https://discourse.psychopy.org/u/hannah1)\
**Post date:** [December 14, 2020, 12:15pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/1 "2020-12-14T12:15:14Z")

</div>

Hello! I’m trying to make a feedback loop saying “Too Slow!” only when they take longer than 1.5 seconds to respond, but it keeps crashing and I’m new to this so would appreciate some help 🙂

This is the code I’ve put in the begin routine tab: (my text response component is called response1)  
if response1.rt \> 1.5:  
continueRoutine = True  
else:  
continueRoutine = False

When I run it it works fine skipping the routine but when it takes longer than 1.5s it crashes and says this instead of showing the message:

TypeError: ‘\>’ not supported between instances of ‘list’ and ‘float’

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [December 15, 2020, 11:38am UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/2 "2020-12-15T11:38:40Z")

</div>

Hello Hannah

the following code should work, at least it worked for me:

```auto
msg = " "
if (response.rt > 1.5):
    msg = "too slow"
    continueRoutine = True
else:
    continueRoutine = False

```

put this in the Begin Routine tab. Place the code-element above your text-element, displaying the feedback message, set the text of your feedback text-element to **$msg** , and set the text to **set every repeat**.

 ![grafik](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/9/5967f4da8b978bc21cb2c09c06b57cac60bb759b.png)

 ![grafik](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/d/0d6c9b794fdffcf93dcde3d197b3af53b0db0891.png)

Best Jens  
P.S. I called the keyboard-element **response** and not **response1**.

---

<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:** [December 15, 2020, 12:04pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/3 "2020-12-15T12:04:56Z")

</div>

I suspect that you are storing all responses in your keyboard component. That would make response1.rt a list. For the most recent rt you need response1[-1].rt

Alternatively, change the routine to only store one response.

However, you also don’t need continueRoutine=True, just have

```auto
if response1[-1].rt <= 1.5:
     continueRoutine=False

```

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [December 16, 2020, 2:56pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/4 "2020-12-16T14:56:06Z")

</div>

Hello

wakecarter’s solution is more elegant and parsimonious. And he found the error that I missed.

Best Jens

---

<div class="post-metadata">

**Author:** ![emmaschmidt](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@emmaschmidt](https://discourse.psychopy.org/u/emmaschmidt)\
**Post date:** [May 19, 2021, 11:57am UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/5 "2021-05-19T11:57:52Z")

</div>

> [@JensBoelte](#):
>
> `msg = " "`

Hi I encountered the error of ‘TypeError: ‘Keyboard’ object does not support indexing’ when implementing similar codes  
`if respKey[-1].rt <= 1.5: msg="too slow"`  
in the Begin Routine. Any suggestion? Thanks!

---

<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:** [May 19, 2021, 12:16pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/6 "2021-05-19T12:16:48Z")

</div>

Sorry – does respKey.rt[-1] work when storing all keyboard responses?

Also, I think you want \>= 1.5 for slow RTs.

---

<div class="post-metadata">

**Author:** ![emmaschmidt](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@emmaschmidt](https://discourse.psychopy.org/u/emmaschmidt)\
**Post date:** [May 19, 2021, 1:57pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/7 "2021-05-19T13:57:29Z")

</div>

Using respKey.rt[-1] gave me another error message of “IndexError: list index out of range”, any idea? thanks  
ps. thanks for noticing it, I used \<=1.5 to debug to show the ‘too slow’ faster 🙂

---

<div class="post-metadata">

**Author:** ![emmaschmidt](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@emmaschmidt](https://discourse.psychopy.org/u/emmaschmidt)\
**Post date:** [May 20, 2021, 8:33am UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/8 "2021-05-20T08:33:37Z")

</div>

My attempts have been revised here (sorry not yet successful but found some consistent errors): I tried moving this section of code from Begin Routine to Each Frame, but I still get the error ‘TypeError: ‘Keyboard’ object does not support indexing’ when I use respKey[-1].rt (also try [0], same error output). Index rt using respKey.rt[-1] (also tried [0]) returned “IndexError: list index out of range.”

---

<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:** [May 20, 2021, 8:50am UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/9 "2021-05-20T08:50:24Z")

</div>

What is your keyboard component called?  
It is in the previous routine, isn’t it?  
Is it saving one key or all keys?  
How does the previous routine end?

---

<div class="post-metadata">

**Author:** ![emmaschmidt](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@emmaschmidt](https://discourse.psychopy.org/u/emmaschmidt)\
**Post date:** [May 20, 2021, 9:02am UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/10 "2021-05-20T09:02:29Z")

</div>

the keyboard component is ‘respKey’.  
Perhaps the issue is that the code (tooSlow, see image below) is located in the current response (resp) routine? I store the last key in the respKey properties and allow three letters that correspond to the $correctAns. The text component used to display the ‘Response too slow’ message on each repeat. The preceding routine is displayed in the image below (showing on the screen 0.15s, no other components in this routine, as well as for fixation)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/0/90c6fed84538c2c3e608298a1f65446e4352d897.png)

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [May 23, 2021, 12:28pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/11 "2021-05-23T12:28:57Z")

</div>

Hello,

the feedback has to follow the response. Put your feedback in routine following your response routine.

Best wishes Jens

---

<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:** [May 24, 2021, 12:14pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/12 "2021-05-24T12:14:54Z")

</div>

This post might help with getting RTs from keyboard lists.

> [@In the competition task, the reaction times of two participants in each trail are compared](https://discourse.psychopy.org/t/in-the-competition-task-the-reaction-times-of-two-participants-in-each-trail-are-compared/23175/2):
>
> @Wenrui , you can use the following in the “End Routine” tab, where your keyboard component is called “key\_resp”, and the keyboard is set to record “all keys”: def getRT(kb, player): # Get first response or return false for no resp idx = 0 for key in kb.keys: if key == player: return kb.rt[idx] idx += 1 return False def getDiff(p1, p2): # draw if abs(p1 - p2) \< .050: return 0 # p1 win elif (p2 - p1) \> .050: return …

---

<div class="post-metadata">

**Author:** ![emmaschmidt](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@emmaschmidt](https://discourse.psychopy.org/u/emmaschmidt)\
**Post date:** [May 25, 2021, 9:18pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/13 "2021-05-25T21:18:02Z")

</div>

Hi Jens thanks for your reply, feedback is indeed missed here. But I added in before ITI so that it won’t disturb the next fixation

---

<div class="post-metadata">

**Author:** ![emmaschmidt](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@emmaschmidt](https://discourse.psychopy.org/u/emmaschmidt)\
**Post date:** [May 25, 2021, 9:19pm UTC](https://discourse.psychopy.org/t/typeerror-not-supported-between-instances-of-list-and-float-feedback-only-after-1-5s/18968/14 "2021-05-25T21:19:05Z")

</div>

@wakecarter thanks! it works now offline, but it is not working online. I will try to debug it. you are being very helpful, thanks!
