B2
hw = “hello world”
#print “hello” using hw
print(hw[0:5:2]
[start: end: step(by how much you go by)]
eg. “hlo would be printed”
start: defaults to 0, is inclusive.
end: defaults to end of the string, exclusive
just putting [:::] sets to defualt
to reverse a string [::-1]
.upper to change into uppercase
.replace() to swap part of the string
Finally in Try and Except:
def safe_divide(a,b):
try:
result = a/b
push pop peek pop
last in first out
Stack 1 stack 2
var: stack1.pop()
stack2. push(var)
#reverse stack.1
while stack.1 is empty() == False
Queue