-3

I am making a dictionary/translator but I want to let the user write, 'hello' and 'Hello' and still receive the result 'Ronne'.

print ("English to Exrian Dictionary")
search = input("Enter the word you would like to translate: ")

if search == "Hello":
    print ("Ronne")
elif search == "Bye":
    print ("Zio")
else:
    print ("No matches were found for '" + search + "'")
Jon Clements
  • 138,671
  • 33
  • 247
  • 280
  • For the sake of completeness, in addition to the `.lower()` approach, you could also do something like `if search in ['Hello','hello']:` -- in this case, it seems less-clear approach than using `.lower()`, but it is still an option to be aware of. – jedwards Jul 31 '16 at 09:39
  • Using `if...elif...` is ok for a couple of words, but if you want to handle a larger number of words you should use a [dictionary](https://docs.python.org/3/tutorial/datastructures.html#dictionaries). – PM 2Ring Jul 31 '16 at 09:42

2 Answers2

1

To ignore the case, just convert your search to lowercase

search = search.lower()
if search == "hello":
    print ("Ronne")
Julien Spronck
  • 15,069
  • 4
  • 47
  • 55
0

You could just convert your input to lowercase, and compare to "hello", like this:

search = input("Enter the word you would like to translate: ").lower()

if search == "hello":
    print("Ronne")
Aurora0001
  • 13,139
  • 5
  • 50
  • 53