Write Letter and Click Enter !!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Atran
    Contributor
    • May 2007
    • 319

    Write Letter and Click Enter !!!

    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.
  • ilikepython
    Recognized Expert Contributor
    • Feb 2007
    • 844

    #2
    Originally posted by Atran
    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().
    [code=python]
    letter = raw_input("Ente r a letter: ")

    if letter == 'a':
    # do one action
    elif letter == 'b':
    # do another action
    [/code]
    Is that what you need, or is there more to it?

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by Atran
      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.
      [CODE=python]usersChoice = raw_input("Ente r your choice (a or b): ")
      if usersChoice == 'a':
      print "doing choice 'a'."
      elif usersChoice == 'b':
      print "doing choice 'b'."
      else:
      print "You've made a bad choice."
      [/CODE]

      Comment

      Working...