+ 7
rule of thumb (not always applies tho)
for loop - if you know how many iterations you need beforehand
while loop - unsure how many iterations, but know of an expected outcome
examples:
7 BOOM with for loop:
for loop to iterate on all numbers from 1 to 100, printing the number or BOOM if the number is divisable by 7
for i in range(1, 101):
if i % 7 == 0:
print("BOOM")
else:
print(i)
Get number length with while loop:
while loop to count the amout of digit in a number
num = 383735
count = 0
while(num > 0):
count+=1
num /= 10
as you can see in the 2nd example, if i used another number with different amount of digits it would still work and give me a different count as there would be more/less iterations delending of the amount of digits



