0

example:

dic = {'a': 'b', 'c': 'd'}
for x, y in dic:
   print(x,y)

would ideally return

a b

but it throws an error instead. so, is there any alternative to doing this:

for x in dic:
    y = dic[x]
user6769219
  • 90
  • 1
  • 11

1 Answers1

1

Try this:

for x, y in dic.items():
   print(x, y)
Danil Speransky
  • 29,891
  • 5
  • 68
  • 79