Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- str_val = input("Enter Dictionary: ")
- #str_val = "{'Jon':100,'Dan':200,'Rob':300,'Nasif':120}"
- str_val = str_val.replace("{", "")
- str_val = str_val.replace("}", "")
- new_str = str_val.split(",")
- summation = 0
- i = 0
- for data in new_str:
- section = data.split(":")
- summation += int(section[1])
- i += 1
- # print(int(summation/i)) #WITH INTEGER TYPECASTING
- print(summation / i) # WITHOUT INTEGER TYPECASTING
Advertisement
Add Comment
Please, Sign In to add comment