With an input file, I'm trying to lowercase the text

Here’s what I’ve tried doing. Simply I purposely put a capital T in one of the "the"s to test out the example given. Do I possibly need to try a raw_input in? I’m only about half way through the curriculum but wanted to reach out as it’s been bugging me.

Thanks in advance! :slight_smile:

Please post your actual code instead of a screenshot. Thanks

Below is the code that works but I get " the 3", I want it to be 4

name = input('Enter a file name: ')
handle = open(name)

counts = dict()
for line in handle :
    words = line.split()
    for word in words :
        counts[word] = counts.get(word,0) +1

bigcount = None
bigword = None
for word,count in counts.items() :
    if bigcount is None or count > bigcount:
        bigword = word
        bigcount = count

print(bigword, bigcount)

I created a file named Frog.txt, Here’s essentially what it reads.

“The little frog and the the the fox.”

Do you want to lowercase all of the words first and then count them? That would get all 4 "the"s

https://www.freecodecamp.org/news/python-lowercase-how-to-use-the-string-lower-function/

Or you are trying to write your own lowercase function as an exercise?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.