Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

python programming (upper and lowercase variables)

Options
  • 06-09-2011 11:41am
    #1
    Registered Users Posts: 27


    Hi anyone,
    i am trying to write a python if statement (i am new to it). i want it to carry out a function if a user enters a value for yes and no. i have it working but it fails if the users types the answer in anything other than lowercase... can anyone help...


Comments

  • Registered Users Posts: 11,264 ✭✭✭✭jester77


    adrian7444 wrote: »
    Hi anyone,
    i am trying to write a python if statement (i am new to it). i want it to carry out a function if a user enters a value for yes and no. i have it working but it fails if the users types the answer in anything other than lowercase... can anyone help...

    Not familiar with python, but I would imagine that there is a toLowerCase function or equivalent that you can use to parse the input string so that you know it will always be in lower case.


  • Registered Users Posts: 27 adrian7444


    thanks i'll look that up


  • Registered Users Posts: 1,311 ✭✭✭Procasinator




  • Registered Users Posts: 27 adrian7444


    i appreciate the link but to be honest i cant follow all that detail.
    this is what i am after....

    condition is as follows;

    if answer=="yes":

    **i want the programme to recognise all variables with yes that the user inputs, not just lowercase**

    i assume i need to put something around the "yes" to allow this.??????????


  • Registered Users Posts: 11,264 ✭✭✭✭jester77


    adrian7444 wrote: »
    i appreciate the link but to be honest i cant follow all that detail.
    this is what i am after....

    condition is as follows;

    if answer=="yes":

    **i want the programme to recognise all variables with yes that the user inputs, not just lowercase**

    i assume i need to put something around the "yes" to allow this.??????????

    if answer.lower()=="yes":

    It doesn't matter what the user inputs, Yes, YES, YeS will all get parsed to yes


  • Advertisement
  • Registered Users Posts: 27 adrian7444


    thanks so much, really appreciate your help...


Advertisement