Reputation: 13
I am new to Python,so I hope someone can help me,Thx!
The program
dict=(zip((3,4,5),('Spring','Spring','Spring')))
why can't I cut the Program like..
dict=(zip((3,4,5),('Spring')))
I have Multiple keys in the dictionary want to point to the same value what can I do...
Upvotes: 1
Views: 53
Reputation: 375744
Dict has a fromkeys
class method that does just what you want:
>>> dict.fromkeys((3, 4, 5), "Spring")
{3: 'Spring', 4: 'Spring', 5: 'Spring'}
Upvotes: 3