+ 1

Multiple keys for the same value?

Is there any way to set up a list of keys such that they all lead to one value without needing to redo each entry? IE: is it possible to make {1:5,2:5,3:5,4:6} into something like {1,2,3:5,4:6}? I've tried both that and using a touple, but the first provides an SyntaxError (obviously) and the second requires you to get the whole touple in order to return its output.

30th Jul 2016, 2:55 PM
hasee500
5 odpowiedzi
+ 2
You really just have to redo each entry mate.
30th Jul 2016, 4:44 PM
Gershon Fosu
Gershon Fosu - avatar
+ 1
Is there a reason why you can't just access the same key?
30th Jul 2016, 4:34 PM
Gershon Fosu
Gershon Fosu - avatar
+ 1
Yeah, the program I'm writing in question is a solubility checker for salts, and it needs to be able to parse different metals. (IE, it should be able to parse Na and K as both leading to soluable salts, even though the elements are different.)
30th Jul 2016, 4:36 PM
hasee500
+ 1
Ah, dang. Well, thank you for helping me!
30th Jul 2016, 4:56 PM
hasee500
+ 1
Possibly you could use a for loop to iterate through each key (if sequential) and assign the value you wish.
9th Aug 2016, 7:10 AM
Luis Rodriguez
Luis Rodriguez - avatar