# If statement not working

**URL:** <https://discourse.psychopy.org/t/if-statement-not-working/4867>\
**Category:** Builder\
**Tags:** code\
**Created:** [July 17, 2018, 5:23pm UTC](https://discourse.psychopy.org/t/if-statement-not-working/4867 "2018-07-17T17:23:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [July 17, 2018, 9:23pm UTC](https://discourse.psychopy.org/t/if-statement-not-working/4867/2 "2018-07-17T21:23:43Z")

</div>

Hi.

Firstly, please follow this advice so that we can correctly interpret the structure of your code:

> [@Please surround python code with backticks](https://discourse.psychopy.org/t/please-surround-python-code-with-backticks/1775):
>
> When you include python code on this forum please put triple “backticks” like this ``` on the line before and the line after your code. If you’ve done it correctly then your code will appear in a grey box with correct indentation like this (check the preview of your post on the right hand side before posting it) and other people will be better able to work out what might be right/wrong with your code. if myVal==True: break If you’ve already posted something that didn’t follow this rule th…

Secondly, it is likely that the issue is that you are comparing to numeric values like `2` when you actually mean to compare to a string value like `'2'`. i.e. for the purposes of getting a response from the keyboard, the `'2'` key is just a letter or symbol like any other key. It isn’t a numeric value, and so needs to be in quotes.

---

_[View the full topic](https://discourse.psychopy.org/t/if-statement-not-working/4867)._
