+ 1

This same as previous code

Why dictionary.has_key() method does not run well and not give expected result? https://sololearn.com/compiler-playground/cH5WKjYqBKOI/?ref=app

29th Jan 2024, 4:46 AM
Oliver Pasaribu
4 Respuestas
+ 6
has_key have been deprecated in Python 3.x use key in dict instead print('A' in Dictionary1) print('For' in Dictionary1 )
29th Jan 2024, 5:03 AM
Bob_Li
Bob_Li - avatar
+ 2
Python language has been around for a very long time, and there is significant difference between version 2 and 3 even in terms of syntax. Python 2 is no longer officially supported, and many old tutorials on the web are not updated. You should try to look for fresh material to learn from, and seek out the latest version and most recent features of Python. Eventually those will be used everywhere. Some newer things like walrus operator, dataclass, async library, pattern matching - are very useful and important, and frequently applied in modern Python code bases, but not covered even in the Sololearn courses.
29th Jan 2024, 8:07 AM
Tibor Santa
Tibor Santa - avatar
0
Thank you for your information that has_kay() has been deprecated. But many python can run this code. I don't understand. Thank you Tibor Santa.
29th Jan 2024, 6:02 AM
Oliver Pasaribu
0
probably because there's still people clinging to Python 2.x
29th Jan 2024, 6:19 AM
Bob_Li
Bob_Li - avatar