list_exercise = ["Ramy", "Victorie", "Letty", "Robin", "Antoine", "Griffin"]
list_exercise.append("Cathy O'neil")
list_exercise + ["Cathy Oneil"]
# a
help(list_exercise.__add__)
# insert first position
["Professor Crast"] + list_exercise
list_exercise.insert(0, "Professor Crast")
print(list_exercise)
# 1
list_exercise.remove("Letty")
print(list_exercise)
# 2
list_exercise.pop()
print(list_exercise)
# solution
index_robin = list_exercise.index("Robin")
print(index_robin)
# solution
list_exercise.count(None)
list_copy = list_exercise.copy()
list_copy.sort()
# notice the modification in place
print(list_copy)
print(list_exercise)
list_copy.append("Lovell")
print(list_copy)
print(list_exercise)
dict_exercise = {"Ramy": "India",
"Victorie":"Haiti",
"Letty":"England",
"Robin":"Canton",
"Antoine":"Nigeria",
"Griffin":"China"}
dict_exercise
keys = list(dict_exercise.keys())
print(keys)
dict_exercise["tiago"]="Brazil"
print(dict_exercise)
# create new
dict_new={"Ramy":dict_exercise.get("Ramy")}
print(dict_new)
# pop
dict_exercise.pop("Ramy")
print(dict_exercise)
# del
del dict_exercise["Victorie"]
print(dict_exercise)
babel = """
That's just what translation is, I think. That's all speaking is.
Listening to the other and trying to see past your own biases to glimpse what they're trying to say.
Showing yourself to the world, and hoping someone else understands."
"""
"Babel" in babel
# count
babel.count("translation")
# where
babel.index("translation")
# see
babel[17:18+len("translation")]
babel.upper()
babel.replace("I ", "We ")
# Define a string containing some punctuation marks.
punctuation = ",'.!"
# Iterate over: we will see this later.
for char in punctuation:
babel = babel.replace(char, "")
print(babel)
!jupyter nbconvert _solution_inclass_python_1.ipynb --to html --template classic