Python Forum
calling a function which takes a dictionary as argument
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calling a function which takes a dictionary as argument
#4
Also note, as your function is altering the dictionary in place there is no need for the return statements.

You could just write this:

dic = {3:0.2, 4:0.5, 5:0.1, 6:0.8, 7:0.34}
  
def function(dic):
   if dic:
      dic[100] = 0.1
  
function(dic)
print(dic[100])
Reply


Messages In This Thread
RE: calling a function which takes a dictionary as argument - by Mekire - Jan-03-2017, 07:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: Diagram.render() takes 1 positional argument but 2 were given sachin1361 0 283 Apr-23-2024, 06:39 AM
Last Post: sachin1361
  mutable argument in function definition akbarza 1 541 Dec-15-2023, 02:00 PM
Last Post: deanhystad
  calling external function with arguments Wimpy_Wellington 7 1,554 Jul-05-2023, 06:33 PM
Last Post: deanhystad
  Calling a function (which accesses a library) from another file mouse9095 4 868 Jun-07-2023, 08:55 PM
Last Post: deanhystad
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,171 Dec-25-2022, 03:00 PM
Last Post: askfriends
  passing dictionary to the function mark588 2 1,045 Dec-19-2022, 07:28 PM
Last Post: deanhystad
  i want to use type= as a function/method keyword argument Skaperen 9 2,013 Nov-06-2022, 04:28 AM
Last Post: Skaperen
  Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given alexfrol86 3 5,973 May-09-2022, 12:49 PM
Last Post: deanhystad
Sad Iterate randint() multiple times when calling a function Jake123 2 2,132 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  Calling a class from a function jc4d 5 1,914 Dec-17-2021, 09:04 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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