Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dictionary and function
#3
def foo(data):
    for value in data.values():
        another_function(value)
If you want only the keys, then use .keys().
If you want both, then use .items()

But first you should learn what a dict is.
Your examples are wrong. If the name AB,AD,BD exists, you get a set and not a dict with your first example. Your second dict is an SyntaxError.


Don't use Python 2.7.x.
The support ends 2020 and even the library developers are stopping the support for Python 2.7
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
dictionary and function - by renu6593 - Apr-03-2019, 09:54 AM
RE: dictionary and function - by perfringo - Apr-03-2019, 09:58 AM
RE: dictionary and function - by DeaD_EyE - Apr-03-2019, 04:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  passing dictionary to the function mark588 2 1,011 Dec-19-2022, 07:28 PM
Last Post: deanhystad
  Writing a lambda function that sorts dictionary GJG 1 2,043 Mar-09-2021, 06:44 PM
Last Post: buran
  Using Dictionary to Test Evenness of Distribution Generated by Randint Function new_coder_231013 6 3,335 Feb-23-2021, 01:29 PM
Last Post: new_coder_231013
  How to pass a dictionary as an argument inside setup function of unittest nilaybnrj 1 3,232 May-11-2019, 03:18 AM
Last Post: keames
  Why does my code not execute? (def function with 'for in' iteration over a dictionary Placebo 3 2,964 Oct-19-2018, 01:32 PM
Last Post: Placebo
  calling a function which takes a dictionary as argument Annie 4 4,597 Jan-04-2017, 07:42 AM
Last Post: Annie
  Python help with module function return dictionary tebirkes 14 15,943 Oct-15-2016, 11:45 PM
Last Post: wavic

Forum Jump:

User Panel Messages

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