Python Forum
Can't unpack values of dictionary with **
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't unpack values of dictionary with **
#1
I've seen similar examples in 4.7.5 Unpacking argument lists, but my somehow don't work.

>>> d={'USA':'Washington','France':'Paris','China':'Beijing'}
	  
>>> **d
	  SyntaxError: invalid syntax
Also:

>>> def f(a,b,c):
	  print(a,b,c)
	  
>>> f(**d)
	  
Traceback (most recent call last):
  File "<pyshell#33>", line 1, in <module>
    f(**d)
TypeError: f() got an unexpected keyword argument 'USA'
Reply


Messages In This Thread
Can't unpack values of dictionary with ** - by Snake - Mar-11-2020, 08:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Using Lists as Dictionary Values bfallert 8 354 Apr-21-2024, 06:55 AM
Last Post: Pedroski55
  Too much values to unpack actualpy 3 483 Feb-11-2024, 05:38 PM
Last Post: deanhystad
  need to compare 2 values in a nested dictionary jss 2 881 Nov-30-2023, 03:17 PM
Last Post: Pedroski55
  Printing specific values out from a dictionary mcoliver88 6 1,431 Apr-12-2023, 08:10 PM
Last Post: deanhystad
  unpack dict menator01 1 1,202 Apr-09-2022, 03:10 PM
Last Post: menator01
  ValueError: not enough values to unpack (expected 4, got 1) vlearner 2 6,340 Jan-28-2022, 06:36 PM
Last Post: deanhystad
Question How to print each possible permutation in a dictionary that has arrays as values? noahverner1995 2 1,764 Dec-27-2021, 03:43 AM
Last Post: noahverner1995
  Getting values from a dictionary brunolelli 5 3,614 Mar-31-2021, 11:57 PM
Last Post: snippsat
  [SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)" Winfried 2 2,877 Mar-30-2021, 07:01 PM
Last Post: Winfried
  Python dictionary with values as list to CSV Sritej26 4 3,034 Mar-27-2021, 05:53 PM
Last Post: Sritej26

Forum Jump:

User Panel Messages

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