0 votes
1 view
in Python by (42.5k points)

I was wondering if there was a way to initialize a dictionary in python with keys but no corresponding values until I set them. Such as:

Definition = {'apple': , 'ball': }

and then later I can set them:

Definition[key] = something

I only want to initialize keys but I don't know the corresponding values until I have to set them later. Basically I know what keys I want to add the values as they are found. Thanks.

1 Answer

0 votes
by (95.7k points)

You could initialize them to None.

Related questions

0 votes
2 answers
0 votes
1 answer
asked Jul 3 in Python by Sammy (42.5k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...