num1 = 15
num2 = num1
help([].extend)
x = [4,5,6]
x.insert(0, [1,2,3])
len(x)
x
x = [4,5,6]
x = [1,2,3] + x
x
["one", "two", "three"].remove("one")
x = ["one", "two", "three"]
x.remove("one")
x
stuff_to_do = [
"buy milk",
"cancel subscription",
"go to work",
"gym"
]
def do_stuff(work):
print(work)
while stuff_to_do:
work = stuff_to_do.pop()
do_stuff(work)
stuff_to_do = [
"work",
"live",
"breath",
"buy milk",
"cancel subscription",
"go to work",
"gym",
"try harder",
"catch zzs"
]
stuff_to_do.pop(stuff_to_do.index('gym'))
stuff_to_do
for i in range(len(stuff_to_do)):
for j in range(i, len(stuff_to_do)):
if stuff_to_do[i] > stuff_to_do[j]:
stuff_to_do[i], stuff_to_do[j] = stuff_to_do[j], stuff_to_do[i]
stuff_to_do
min = stuff_to_do[0]
for i in range(len(stuff_to_do[1:])):
if min > stuff_to_do[i]:
min = stuff_to_do[i]
print(min)
for i in range(len(stuff_to_do)):
min_j = i
min = stuff_to_do[min_j]
for j in range(i+1, len(stuff_to_do)):
if min > stuff_to_do[j]:
min_j = j
min = stuff_to_do[min_j]
stuff_to_do[i], stuff_to_do[min_j] = stuff_to_do[min_j], stuff_to_do[i]
print(stuff_to_do)
sorted(stuff_to_do, reverse=True)
lists = [
[2, 2000],
[1,1,1],
[100, 75],
[50, 50, 90],
[10, 20, 30]
]
sorted(lists, key=len)
sorted(lists, key=max)
sorted(lists, key=min)
sorted(lists, key=max)
import math
help(math.pow)
sorted(lists, key=str)
sorted(lists, key=sum)
help(sum)
lists2 = [
[10, 20, 30],
[100, -100],
[15, 75],
[1000, 500, 200, 50]
]
sorted(lists2, key=min)
sorted(lists2, key=max)