SHARE
TWEET

Untitled

a guest Oct 15th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fruit=[('mango',3),('apple',2),('mango',2)]
  2. fruit_df ={}
  3. for i in fruit:
  4.     if i[0] in fruit_df: #found
  5.         fruit_df[i[0]]= (i[1]+fruit_df[i[0]])
  6.     else:
  7.         fruit_df[i[0]] = i[1]
  8. print(fruit_df)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top