By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,089 Members | 2,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,089 IT Pros & Developers. It's quick & easy.

Write Letter and Click Enter !!!

Atran
100+
P: 319
Hello, when my application run, I want when I write 'a' and click enter, it do an action. But when I write 'b' and click enter, it do another action.
Thanks for anyhelp.
May 30 '07 #1
Share this Question
Share on Google+
2 Replies


ilikepython
Expert 100+
P: 844
Hello, when my application run, I want when I write 'a' and click enter, it do an action. But when I write 'b' and click enter, it do another action.
Thanks for anyhelp.
That's a simple matter of input using raw_input().
Expand|Select|Wrap|Line Numbers
  1. letter = raw_input("Enter a letter: ")
  2.  
  3. if letter == 'a':
  4.     # do one action
  5. elif letter == 'b':
  6.     # do another action
  7.  
Is that what you need, or is there more to it?
May 30 '07 #2

bartonc
Expert 5K+
P: 6,596
Hello, when my application run, I want when I write 'a' and click enter, it do an action. But when I write 'b' and click enter, it do another action.
Thanks for anyhelp.
Expand|Select|Wrap|Line Numbers
  1. usersChoice = raw_input("Enter your choice (a or b): ")
  2. if usersChoice == 'a':
  3.     print "doing choice 'a'."
  4. elif usersChoice == 'b':
  5.     print "doing choice 'b'."
  6. else:
  7.     print "You've made a bad choice."
  8.  
May 30 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.