+ 1
Need to search a string in text file irrespective of case sensitive
https://code.sololearn.com/co3DMeQvBn88/?ref=app Please help me
2 ответов
+ 2
If you just need to determine whether the text is in the file or not, try the following:
with open("test.txt") as f:
if 'Apple'.lower() in f.read().lower():
print('yes')
(or switch "Apple" to anything, a variable which you can convert to lowercase on-the-fly)
But...
if you need a more sophisticated search, try learning regex and use it:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2475/
+ 1
Thank you