Hello, William

On 09/11/2013 06:39 AM, William Bryant wrote:
 > user_input1 = input(prompt)

I take it you are using Python 3.x . If that's not the case, take a look at raw_input().



def NOS():
     if user_input1 == "String" or user_input1 == "string" or user_input1 == "STRING" or user_input1 == 
"s" or user_input1 == "S" or user_input1 == "str":
         print("a")


What if you create a list containing these, and then you check if the user_input is contained in that list. But before that, get the lower-case of it so you don't deal with String sTring string, s, S, etc...

Something like this

You add this to the variables you are using section

string_list = ['string', 's']



When you want to check the check

if user_input.lower() in string_list:
        {your_code_here}


     elif user_input1 == "Number" or user_input1 == "number" or user_input1 == "NUMBER" or user_input1 == "N" 
or user_input1 == "N" or user_input1 == "int" or user_input1 == "num":
         print("a")


Same goes with that


But some questions:

1 - Why does the user have to specify that, why doesn't the program itself tell if it is a string or a number ? You just give it the data and it's up to him to tell.

2 - What is it you are trying to accomplish: Maybe there are shortcuts or better ways to do things.





--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to