Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (47.6k 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 (106k points)

You could initialize them to None.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
asked Jul 3, 2019 in Python by Sammy (47.6k points)

Browse Categories

...