How Do I Make This Character Counter Be Insensitive To Case?
I wrote this little code to count occurrences of words in a text: string=input('Paste text here: ') word=input('Type word to count: ') string.count(word) x=string.count(word) print
Solution 1:
Convert both the text and the word you're searching for to uppercase.
string.upper().count(word.upper())
Since strings are immutable, it won't permanently change the text or the word.
Post a Comment for "How Do I Make This Character Counter Be Insensitive To Case?"