[Tutor] Need help with python keyboard press/navigation commands

akuma ukpo johnnyukpo at gmail.com
Tue Mar 12 04:59:13 CET 2013


This is the problem

Implement a function called get_direction which, on a particular character
, gives the
direction corresponding to that character. The correspondences are as
follows:
 The character ’w’ corresponds to the direction ’North’
 The character ’a’ corresponds to the direction ’West’
 The character ’s’ corresponds to the direction ’South’
 The character ’d’ corresponds to the direction ’East’


I am having difficulty coming up with a function and testing it as well.

I have tried

def get_direction(self):
        """
        whenever a key is pressed the character moves to
        the direction corresponding to the key
        """
        'North':w
        'South': s
        'East' : d
        'West' : a

but it didn't work...please help.
-- 
*Akuma*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130311/aa56b5d6/attachment.html>


More information about the Tutor mailing list