difference is in how they behave at the end of an if clausethe program execution continues after the if statement but at the end of while clausethe program execution jumps back to the start of the while statement the while clause is often called the while loop or just the loop let' look at an if statement and while loop that use the same condition and take the same actions based on that condition here is the code with an if statementspam if spam print('helloworld 'spam spam here is the code with while statementspam while spam print('helloworld 'spam spam these statements are similar--both if and while check the value of spamand if it' less than they print message but when you run these two code snippetssomething very different happens for each one for the if statementthe output is simply "helloworld but for the while statementit' "helloworld repeated five timestake look at the flowcharts for these two pieces of codefigures - and - to see why this happens start true spam print('helloworld 'spam spam false end figure - the flowchart for the if statement code