-
Notifications
You must be signed in to change notification settings - Fork 2
/
list of functions
46 lines (44 loc) · 1.52 KB
/
list of functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
https://peps.python.org/pep-0008/#fn-hi
# peps8 is a rule book on how to correctly stylize your code
title() # to capitalize each word
upper()
lower()
strip() # remove white space on both sides of words
rstrip() # remove on right only
lstrip() # remove on left only
split() # turn variables into lists
# example bikes = "ducati honda kawasaki"
# bikes = bikes.split()
# print(bikes)
# >>> ['ducati', 'honda', 'kawasaki']
# print(bikes[-1])
# >>>kawasaki
tuple makes an unmodifiable list
# example bikes = (red, blue, grey)
# example bikes = (red,)
append() # add additional item at end of list
# example bread = []
# bread.append['rye']
# bread.append['wheat']
# print(bread)
# >>>['rye', 'wheat']
insert() # add a new element at any position in your list
# example car = ['red', 'blue']
# car.insert(1, 'yellow')
# print(car)
# >>>['red','yellow','blue']
del # remove item
# del car(1)
pop() # remove and use item from list
# popped_car = car.pop(3)
print(popped_car)
remove() # if I know value but not positiion of item
sorted() # sort list in alphabetical order
reverse() # sort in reverse alphabetical order
len() # count items in list or characters and whitespace in variable
friend_foods = my_foods[:] # copies list by using [:] without it would
# able to add items to first list or make them different
dictionary # variable = {'key': 'value', 'key': value, 'key': ['value'],
'key': "value", 'key': {'key': 'value'}}
import time
time.sleep() #add pauses between strings