Skip to main content

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:
code:
userdict = {'e': goeast, 'exit': endgame, 'help': helpfunc, 'l': look, 'n': gonorth, 's': gosouth, 'storage': lookstorage, 'take': takeitem, 'w': gowest}
and can make 2 keywords same value? example 'e' , 'east' value goeast, without repeating myself?

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

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support