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
  • 9

1 Answers1

1

Try this:

for x, y in dic.items():
   print(x, y)
Danil Speransky
  • 28,931
  • 5
  • 62
  • 77