title: how to build a sorting key function in python?
body: <p>im now learning in online course and not struggling with this exercise:
  ive got a list of tuples:</p>
  
  <pre><code> [("candy","5.5"),("banana","2.3"),("chocolate","4.4")] 
  </code></pre>
  
  <p>I need to build a function that sorts the tuple by prices. for that i need to build a key function i can put in <code>sorted()</code> and i dont get how it should be like.
  ive tried this:</p>
  
  <pre><code>def choose_sec(my_list, new_list =[]):
    for i in my_list:
    new_list += i[1]
    for i in new_list:
      return int(i)
  </code></pre>
  
  <p>please help me</p>