""" The While Loop Structure: while (condition is true): Do Stuff A while loop is just an IF statement that repeats as long as its condition is true. Each time it runs (finishes the code inside) it will check the condition again to see if the loop should run another time. Make sure your condition will eventually become false or else your while loop will run FOREVER While loops are best suited for situations where we don't know beforehand how many times it will need to run, for example a password checker """ #This loop will run so long as counter < 5 counter = 0 while(counter < 5): print("hello") counter = counter + 1 print("all done!", counter) """ #Who knows how many tries I need to guess the password password = input("Whats the password?") while(password != "password"): password = input("Whats the password?") """ """ The FOR Loop Used specifically in cases where we know how many times the loop needs to run You need a counting variable to keep track of how times it has run so far and something like a condition to control it. In the example we are running a loop with a variable 'count' that counts from 0 to 4. 0,1,2,3,4 range(0,5) will give you 0,1,2,3,4 But NOT 5 its like a < VS <= situation """ for count in range(0,5): print(count, " hello") data = "Hello world" #11 characters #This index values (locations) go from 0 - 10 (thats 11 because we count the zero for count in range (0, 11): #0 - 10 print(data[count]) #Here is an example where I put loops and strings together to make an ASCII # graphic. In the future I'll make it look much better, and way shorter. print("") levelOne = "1000000001" for c in range (0, 10): if levelOne[c] == "1": print("|", end="") elif levelOne[c] == "2": print("P", end="") else: print(" ", end="") print("") levelOne = "1000200001" for c in range (0, 10): if levelOne[c] == "1": print("|", end="") elif levelOne[c] == "2": print("P", end="") else: print(" ", end="") print("") levelOne = "1000000001" for c in range (0, 10): if levelOne[c] == "1": print("|", end="") elif levelOne[c] == "2": print("P", end="") else: print(" ", end="") """ TO DO 1) password check, make the password whatever you want 2) After the user enters the correct password, display the number of tries they took 3) Greet the user properly. Say "Hello" the number of times the user took to get the password. Serparate lines in fine. 4) BONUS: Make a String of characters. Display the number of g's that are in the string. """