Thread: breaking down a dictionary in python
i'm creating simple text adventure in python. takes commands user input , checks in dictionary, , values references functions. i'm creating more functions(more stuff in world) dictionary getting bigger. , looks bad let grow on 1 line. must done if it's going bigger.
there proper way break down dictionary? or should cut down \ knife pleases me?
dictionary:
and can make 2 keywords same value? example 'e' , 'east' value goeast, without repeating myself?code:userdict = {'e': goeast, 'exit': endgame, 'help': helpfunc, 'l': look, 'n': gonorth, 's': gosouth, 'storage': lookstorage, 'take': takeitem, 'w': gowest}
just put them on separate lines.
code:def main(): some_dict = { "a" : 1, "b" : 2, "c" : 3, } pair in some_dict.items(): print pair if __name__ == "__main__": main()
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] breaking down a dictionary in python
Ubuntu
Comments
Post a Comment