Some lesson
I'm writing some lesson stuff -AJ
I = 1
while I < 5:
print(I)
I += 1
It was talking about a statement going through a condition until it's true
The videos use a fake coding language that doesn't really have a 1:1 translation to python or javascript. The other two videos were talking about REPEAT functions and REPEAT UNTIL functions. The repeat function will repeat a function a set number of times and the repeat until is basically a while function
list = [1, 2, 3, 4]
for n in list:
print("i")
You can emulate a repeat function using a for loop, like I did above. It'll loop for each item in the list, so you can plug in a list that has the same amount of items as you want loops.
list = [1, 2, 3]
print(list)
print(list[2])
list.append(4) #add a variable to the end of the list
print(list)
list.pop(1) #remove the variable at a chosen index
print(list)
list.insert(1, 2) #insert a variable in a specified spot. Index first, then desired variable
print(list)
x = list[1] #make x into the variable at index 1
print(x)
print(len(list))
This is basically everything they listed that you can do with lists.
The second video also talks about for loops. They insert if statments to count things in a list, though
list = ["cat", "dog", "dog", "cat", "cat", "cat"]
d = 0
c = 0
for n in list:
if n == "dog":
d += 1
if n == "cat":
c += 1
print(list)
print(d)
print(c)
The third video was about recursive loops. It was using a function that looped to remove words that were 3 letters long.
list = ["men", "boom", "gamer", "big", "no"]
def recursive_loop(n):
if n < len(list):
if len(list[n]) == 3:
list.pop(n)
recursive_loop(n + 1)
print(list)
recursive_loop(0)
print(list)
That's basically what they did in the third video. code written by Drew.