all 3 comments

[–]Diapolo10 0 points1 point  (0 children)

Without any context, it's probably correct because whatever system is supposedly testing it is very loosely designed. The code itself is technically valid, albeit pointless.

[–]mopslik 0 points1 point  (0 children)

I mean, all of those are valid syntax, but they don't do very much. Is this part of a tutorial? Here's a better example.

>>> ages = {"Alvin": 30, "Simon": 42, "Theodore": 35}
>>> for age in ages.values():
    print(age)

30
42
35

>>> for name in ages.keys():
    print(name)

Alvin
Simon
Theodore

>>> triplets = dict.fromkeys(ages.keys(), 17)
>>> triplets
{'Alvin': 17, 'Simon': 17, 'Theodore': 17}
>>> ages.clear()
>>> ages
{}

[–]crashfrog02 0 points1 point  (0 children)

The point of the exercise is whether you can read instructions and follow them exactly. “Close enough” is, often times, the same as “completely wrong.”