# FAQ: Loops - do while

This community-built FAQ covers the “do while” exercise from the lesson “Loops”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise do while

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like () to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

<?php \$plant_height = 22; do{echo "The plant is \$plant_height tall.\n"; \$plant_height++; if(\$plant_height >= 30){echo "And can produce fruit.";}else{}}while(\$plant_height<=30); I did this as the instruction says ' When the plant is greater than or equal to 30, you should print `"And can produce fruit." ', however, this actually outputs 'The plant is 22 tall. ...... The plant is 29 tall. And can produce fruit.The plant is 30 tall. And can produce fruit.' instead when I change the if condition to '\$plant_height >30', the output becomes ' ... The plant is 29 tall. The plant is 30 tall. And can produce fruit.' just like the exercise expects . is there any error in my code ?

when you want to paste your code for us to read it, you should use the button </> on top of the text box and then paste your code where it says so. That way, it’s gonna be easier for us to read it and help you out.

the result will look like this

<?php
\$plant_height = 22;

do {
echo "The plant is \$plant_height tall.\n";
if (\$plant_height >= 30) {
echo "And can produce fruit.\n";
}
\$plant_height++;
} while (\$plant_height <= 30);

your problem is that you didn’t put the if code at the right place, i figured it out by trying to put it in the beginning of the do loop, then after the echo and finally after the \$plant_height++ . Coding is all about trying, making mistakes, learning from them and searching the net