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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

python programming (upper and lowercase variables)

  • 06-09-2011 10:41am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 27 adrian7444


    thanks i'll look that up


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




  • Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 27 adrian7444


    thanks so much, really appreciate your help...


Advertisement