What is the problem with for loop?


#1

I tried with everything ? not even using the browser for a day. still the same issue.
I know my syntax is right. how do i get past the for loop. I don't want to stuck on the loop.


#2

What issue? Can you paste your code there using this format and tell us the error your receiving. Thankyou


#3

code looks fine to me. when its being excuted, it goes to infinite loop and have to restart the tab.
Help me out pls

<html>
  <head>
    <title>Solo For Loop!</title>
  </head>
  <body>
    <p>
      <?php
      // Write your for loop below!
      for ($i = 0; $i < 101; $i = $i + 10) {
    echo $i;
}
      ?>
    </p>
  </body>
</html>

#4

<?php
// Write your for loop below!
for ($i = 0; $i < 101; $i = $i + 10) {
echo $i;
}
?>

I copy pasted your code nd it gave me no problem what so ever. No infinite loop.. May i ask which browser do you use? (Google Chrome is the better browser for codecademy) and if thats not the case can you try refreshing? Thakyou


#5

i am using chrome. I finished all the other chapter but when i use for loop it use infinte loop. no matter what i do its become unsolve.


#6

Well ill ask the codecademy moderators/managers for help... This seems like a issue i cant solve(sorry :frowning: ) . @CodecademyModerators


#7

I am having the same issue.I donot seem to go past the for loop level for like 3 straight days.Its frustrating


#8

Had the same issue here as well, although when I copied and pasted the code from above it worked, even though there was literally no difference between it and what I had typed before? I've been having issues all week with this lesson, I keep having to refresh the page to get it to work again. I thought it was my internet connection, but now I'm not so sure...


#9

I'm having the same issue as well, says an infinite loop then that I have a syntax error on line 9 when I don't. Error: Parse error: syntax error, unexpected ')', expecting ';' on line 9. Also I'm using chrome Version 49.0.2623.87 m, The error seems to come when I type the code. But when I take my same code and copy paste it in after a browser refresh it works. I'm guessing when you type it in since the editor is constantly evaluating it theres a point where you write an infinite loop (before you add the last argument of the for loop) and I think the editor is getting hung up there even after you finish completing the code. But thats just my newbie guess.

<html>
  <head>
    <title>Solo For Loop!</title>
  </head>
  <body>
    <p>
      <?php
      // Write your for loop below!
        for ($i = 0; $i <= 100; $i = $i + 10) {
                echo $i;
            }
      ?>
    </p>
  </body>
</html>

#10

<?php
// Write your for loop below!
for ($i = 0; $i < 101; $i = $i + 10) {
**** echo $i;
}
?>

I think the mistake is in the indenting being used . I have put the stars to just indicate the indenting.


#11

You don't have to do that.
To format your code to make it visible:
1. Paste your code in.
2. Insert 3 backticks (`) before and after your code:

```
Code goes here
```

#12

The problem still persists on the FOR LOOP.

Does not work on both Firefox and Chrome


#13

I got it by copying the example on the left and editing it.
Hope that helps


#14

I got it to finally work by removing the spaces around the '+' in the 3rd part of the loop. Example:

Does not work:

for ($i = 0; $i < 101; $i = $i + 10) {
echo $i;
}

Works:

for ($i = 0; $i < 101; $i = $i+10) {
echo $i;
}


#15

it only works with "$i" for some reason...

Here is my code







<?php
// Write your for loop below!
for ($i = 0; $i <= 101; $i = $i + 10) {
echo $i;
}
?>




#16

Working Fix:

1.Clear browser cookies.
2.Change <?php to <?ph or something so that the processor doesn't run.
3.Type the code you want to type and make sure there is no infinite loop.
4.Change <?ph or whatever you changed it to, back to <?php


#17

Just refresh the page and try again. It worked for me.


#18

This problem still persists. I'm guessing a bug in the website or something..


#19

I finally got this to work. Pasted each example in the above comments with no luck. Cleared cookies then pasted example. Now it works.


#20

Having the exact same problem - I have written the code and checked the example and it matches perfectly but it either tells me I have an infinite loop (looking at the above, I don't) or it just fails to submit and sits there validating indefinitely. I've tried clearing cache and cookies and re-writing the code but the same occurs every time.