خرید بک لینک

Vote count: 0

I am pretty new to python, but I know the basic commands. I am trying to create a for loop which, when given a list of sentences, adds a key for the length of each sentence. The value of each key would be the frequency of that sentence length in the list, so that the format would look something like this:

dictionary = {length1:frequency, length2:frequency, etc.}

Here is the code I have:

dictionary = {}
for i in sentences: 
    dictionary[len(i.split())] += 1

When I try to run the code, I get this message: "SyntaxError: multiple statements found while compiling a single statement." I am not sure if this is a problem with the loop, or with the sentences themselves (I created them by using a .split(".") on a text file, which is obviously very basic, but the requirements of the assignment are also very basic). Any help fixing my code and an explanation of where I went wrong would be so appreciated!

asked 1 min ago

برچسب: how to build a deck,how to build credit,how to build a house,how to build muscle,how to build a shed,how to build a computer,how to build a fire pit,how to build a website,how to build a resume,how to build a retaining wall, نویسنده: استخدام کار تاريخ: دوشنبه 15 شهريور 1395 ساعت: 7:12

صفحه بندی