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 96 views
2 answers 159 views
1 answer 193 views
1 answer 85 views
1 answer 100 views
...