class Dictionary:
elements = {}
def __init__(self):
[Link] = {}
def newentry(self, key, value):
"""Add a new entry to the dictionary."""
[Link][key] = value
def look(self, key):
"""Look up an entry in the dictionary."""
return [Link](key, "Cant find entry for " + key)
d = Dictionary()
[Link]("Apple", "A fruit that is red or green.")
print([Link]("Apple"))
print([Link]("Banana"))
def get_total(costs, items_bought, tax):
subtotal = sum(costs[item] for item in items_bought)
total = subtotal * (1 + tax)
return round(total, 2) # Redondeamos a 2 decimales
costs = {'socks':5, 'shoes':60, 'sweater':30}
print(get_total(costs, ['socks', 'shoes'], 0.09))
def new_word(words):
return ''.join(word[i] for i, word in enumerate(words) if i < len(word))
word = new_word(["yoda", "best", "has"])
print(word) # Output: "ye