On 18/04/13 18:14, Danilo Chilene wrote:
for command in commands: if arg in commands: print commands[command] else: print 'Invalid command'
I don't understand what you are doing here? Its almost a random selection mechanism? You print the command for every item in commands if arg is in commands and Invalid Command for every command if its not?
Whatever its trying to do its massively inefficient. I thought you'd have wanted something like for command in commands: if arg == command: print commands[command] else: print 'Invalid command' Which is roughly equivalent to: print commands.get(arg, 'Invalid command') but much less efficient! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor