-3

Code:

str1 = input("Please enter a full sentence: ")
print("Thank you, You entered:" , str1)

str2 = input("Now please enter a word included in your sentence in anyway you like: ")

if str2 in str1:
    print("That word was found!")
else:
    print("Sorry, that word was not found")

I have done some research on forums etc and the only solutions i can find for this subject are converting words into uppercase/lowercase. I don't want to do it like that.

I want something that will ignore the fact that it is uppercase or lowercase and will assume it to be the same word, so when someone inputs a sentence it will automatically assume it t be the same word. For example: (Treat = treat, TREAT, TreAT etc). So it will essentially read the characters in the word and will ignore the uppercase/lowercase letters.

I do have something (string.ascii_letters) which i think might do it, but if anyone know any better way of doing it then that would be greatly appreciated! :)

LukeP_8
  • 199
  • 3
  • 5
  • 12
  • 4
    why can't you compare `Treat.lower() == TREAT.lower()`? – depperm Sep 07 '16 at 17:39
  • Because i don't want to have to convert all the characters into upper/lower case. I'd rather keep all the words the same as the input but treated the same. – LukeP_8 Sep 07 '16 at 17:47
  • i have edited the original question which has my code, happy now? Now stop treating me like I'm mentally simple – LukeP_8 Sep 12 '16 at 16:31

2 Answers2

2
"Treat".lower()

will give you the lowercase value of a string. ie: "treat" in the above example

If you want it in a function.

def function_name(s):
    return s.lower()

print function_name("Treat")
Marlon Abeykoon
  • 11,927
  • 4
  • 54
  • 75
2
"DenvAAr".lower()
"Denvaar".lower()
"denvaar".lower()

All yield the same result: denvaar

denvaar
  • 2,174
  • 2
  • 22
  • 26