# What is wrong with this code?

**URL:** <https://discourse.processing.org/t/what-is-wrong-with-this-code/6089>\
**Category:** Coding Questions\
**Created:** [November 29, 2018, 10:25pm UTC](https://discourse.processing.org/t/what-is-wrong-with-this-code/6089 "2018-11-29T22:25:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CowPieForever](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@CowPieForever](https://discourse.processing.org/u/CowPieForever)\
**Post date:** [November 29, 2018, 10:25pm UTC](https://discourse.processing.org/t/what-is-wrong-with-this-code/6089/1 "2018-11-29T22:25:50Z")

</div>

This is my code:

 ![21%20PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cc205c91d6028c894d76ff2e979e38d208b76db3.png)  
however, whenever I run it, it gives me the error “expecting }, found ‘else’”. I’ve gone through it multiple times and I have no idea whats going wrong. Please help.

---

<div class="post-metadata">

**Author:** ![Jan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jan/32/2572_2.png) [@Jan](https://discourse.processing.org/u/Jan)\
**Post date:** [November 29, 2018, 10:55pm UTC](https://discourse.processing.org/t/what-is-wrong-with-this-code/6089/2 "2018-11-29T22:55:17Z")

</div>

Line 8 and 12  
No Semicolon. 🙂

---

<div class="post-metadata">

**Author:** ![CowPieForever](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@CowPieForever](https://discourse.processing.org/u/CowPieForever)\
**Post date:** [November 29, 2018, 11:05pm UTC](https://discourse.processing.org/t/what-is-wrong-with-this-code/6089/3 "2018-11-29T23:05:11Z")

</div>

there are semicolons on those lines. when I run it, it tells me “expecting }, found ‘else’”, yet all my {}s are in the right location

---

<div class="post-metadata">

**Author:** ![Jan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jan/32/2572_2.png) [@Jan](https://discourse.processing.org/u/Jan)\
**Post date:** [November 29, 2018, 11:17pm UTC](https://discourse.processing.org/t/what-is-wrong-with-this-code/6089/4 "2018-11-29T23:17:59Z")

</div>

No you got me wrong. you have to get rid of the semicolons.

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [November 29, 2018, 11:30pm UTC](https://discourse.processing.org/t/what-is-wrong-with-this-code/6089/5 "2018-11-29T23:30:59Z")

</div>

In the future, please paste your code as text instead of as a screenshot.

@Jan is correct: you have extra semicolons in your code.

Note that it’s possible to put code inside `{ }` curly brackets. This is fine:

```auto
void setup(){
  size(500, 500);
  {
    background(32);
    ellipse(250, 250, 50, 50);
  }
} 

```

You can also put a semicolon after an if statement:

```auto
if( thingIsTrue );

```

This basically means: if thingIsTrue, then do nothing.

What you have is a combination of both of the above concepts:

```auto
if(mousePressed);
{
  triangle(mouseX, height-mouseY, 58, 662, 86, 27);
  ...
}

```

This code says: if mousePressed, then do nothing. After that, always execute the code inside these `{ }` curly brackets.

You’re getting an error because then you have an `else` statement, which doesn’t make sense in the above context.

Jan is right: get rid of the semicolons after your `if` statements.
