Problem regarding this While exercise


#1


https://www.codecademy.com/courses/web-beginner-en-5YvPF/0/3?curriculum_id=5124ef4c78d510dd89003eb8#


I get the following error: "Parse error: syntax error, unexpected $end on line 32". But I don't have line 32 on my code...


<html>
    <head>
		<title>A loop of your own</title>
        <link type='text/css' rel='stylesheet' href='style.css'/>
	</head>
	<body>
    <?php
	//Add while loop below
    echo "<p>we are going to toss a coin until we get three heads.</p>";
	
	$headcount = 0;
	$flipcount = 0;
	
	while ($headcount < 3) {
	    $flip = rand (0,1);
	    $flipcount ++;
	    if ($flip = 1) {
	        echo "<p>head<\p>";
	        $headcount ++;
	    }
	        else {
	        echo "<p>tail<\p>";
	        $headcount = 0;
	        {
	}
	
	echo "<p>it took $flipcount flips.</p>";
    ?>
    </body>
</html>


#2

You've used the wrong curly braces to close your else statement after $headcount = 0.

	......
	        else {
	        echo "<p>tail<\p>";
	        $headcount = 0;
	      {

Should be

	......
	        else {
	        echo "<p>tail<\p>";
	        $headcount = 0;
	      }

#3

Thank you so much for your help!!!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.