Python Forum
logic comparater based on dictionary values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
logic comparater based on dictionary values
#4
(Oct-16-2017, 03:56 AM)ijosefson Wrote: I would like to iterate through each value and verify they are positive.
Well, you are going to need to try iterating then:
some_dict = {"a" : 5, "b" : 7, "c" : 9}


for key in some_dict:
    print(key)

for val in some_dict.values():
    print(val)

for key,val in some_dict.items():
    print(key, val)
Reply


Messages In This Thread
RE: logic comparater based on dictionary values - by Mekire - Oct-16-2017, 06:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace based on values in a file WJSwan 2 1,638 Jan-30-2023, 04:38 PM
Last Post: deanhystad
  create empty sets for keys in a dictionary and add values to the set naughtysensei 1 2,623 Nov-03-2020, 08:32 AM
Last Post: DeaD_EyE
  Dictionary based exercise garvind25 2 2,077 Jul-12-2020, 06:53 PM
Last Post: garvind25
  Formatting data based on DataFrames values 577e94982d620b84f7c536d5e76f1e 0 2,138 Dec-03-2018, 02:23 AM
Last Post: 577e94982d620b84f7c536d5e76f1e
  Dictionary based assignment: Need help RoyceJ 6 4,065 Aug-29-2018, 05:30 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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