How to case insensitive search in a list with Python

2 Answers

0 votes
lst = ['Python', 'JAVa', 'c', 'c++', "Rust"]

searchfor = 'java'

print(searchfor.lower() in [s.lower() for s in lst])

  
  
  
'''
run:

True

'''

 



answered Mar 3, 2023 by avibootz
0 votes
lst = ['Python', 'JaVa', 'c', 'c++', "RuSt"]

searchfor = 'RUST'

print(searchfor.lower() in [s.lower() for s in lst])

  
  
  
'''
run:

True

'''

 



answered Mar 3, 2023 by avibootz

Related questions

1 answer 89 views
2 answers 152 views
1 answer 185 views
1 answer 77 views
1 answer 93 views
...