-1

I have the following script:

ip = input('Enter your string: ')
if 'tree' in ip:
   print('Correct string')

I would like to print 'Correct string' even if the user input is 'TREE' or 'tree' based on the case. How do I do that (optimally rather than using else or elif)?

If the input from the user is 'TREE' then the script should give an output:

CORRECT STRING

If the input from the user is 'tree' then the script should give an output:

correct string

How do I do that?

MuSu18
  • 159
  • 9

1 Answers1

1

Convert the user input to lower case as:

ip = input('Enter your string: ').lower()
if 'tree' in ip:
   print('Correct string')
Krishna Chaurasia
  • 8,924
  • 6
  • 22
  • 35