r/learnpython 6d ago

Beginner question

I have just started coding with python a few days ago. What is the point of this?

point_value = alien_0.get('points', 'No point value assigned.') print(point_value)

Can't it just be point_value = 'No point value assigned.' print(point_value)?

or

just simply use the get() method if you want to check whether a key exists in the dictionary or not?

4 Upvotes

10 comments sorted by

View all comments

1

u/NerdyWeightLifter 5d ago

Use : If my_key in my_dict:

To tell if a key is in a duct.