Python Forum
average of values in dict with use of for
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
average of values in dict with use of for
#7
Last post was sort of a test to see if i can comunicate properly on this forum. Which i guess i can not edit now.

dic={"123/2018":8,"124/2017":6,"125/2018":7,"126/2017":9}
del dic["124/2017"] #ili dic.pop("124/2017")
dic["435/2018"]=6
print(dic)

med=0
for i in dic.values():
    med+=i
    
med=med/len(dic)
#med=sum(dic.values())/len(dic)
print(med)
Solved by a friend
Reply


Messages In This Thread
RE: Thread opened by a newbie - by buran - Apr-28-2020, 10:56 AM
RE: Thread opened by a newbie - by deanhystad - Apr-28-2020, 12:33 PM
RE: Thread opened by a newbie - by perfringo - Apr-28-2020, 01:24 PM
RE: Thread opened by a newbie - by Daromir - Apr-28-2020, 05:09 PM
RE: Thread opened by a newbie - by perfringo - Apr-29-2020, 05:26 AM
RE: Thread opened by a newbie - by deanhystad - Apr-28-2020, 05:52 PM
RE: Thread opened by a newbie - by Daromir - Apr-28-2020, 06:00 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020