Python – Can't combine two dictionaries

Question:

Below this line of text is my code. Please see below. Python 3.11.

d = test_login('poo', 'poo')
a = test_login('doo', 'doo')
big_d = d | a
print(big_d)

It is only printing the a dict. But if I specifically print d, there is data.

Asked By: solidstatestarfish

||

Answers:

If d and a are dictionaries then :

d = {'poo': 'poo'}
a = {'doo': 'doo'}

print(d | a)

{'poo': 'poo', 'doo': 'doo'}
Answered By: God Is One
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.