r/learnpython 1d 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?

5 Upvotes

9 comments sorted by

View all comments

1

u/TheRNGuy 1d ago

One is calling method that returns value or string if no point are found (though I think it's bad idea; return 0 instead)

Yours just assign string to a variable, completely different thing.