Hello can anyone help me??!! | SoloLearn: Learn to code for FREE!

+1

Hello can anyone help me??!!

Hello can anyone help me??!! I have started the python data structures course 2 weeks ago and I am stucked on the project average word length I am trying and trying but I didn't guess the correct output. Can anyone help me to do it??

2/26/2021 9:19:32 AM

Sachet Bansod

16 Answers

New Answer

+6

Sachet Bansod I have just reviewed the challenge. The trick with this challenge is that the space between the letters is also counted as a character. This means that: "this is a test" has 14 characters but 11 letters. average is 11/4 not 14/4, so you will need to find a way to identify the letters, or identify the space.

+11

a=input() a=a.strip() a=a.split("\n") list=[] for i in a: i=i.strip() list+=i.split(" ") size=len(list) asize=0 for i in list : asize+=len(i) str=list[len(list)-1] if((asize%size)!=0): if(str[len(str)-1]=="?"): print(int((asize//size))) else: print(int((asize//size)+1)) else: print(int(asize//size))

+4

Do you have a code to attach with your request. This helps us see where you are having trouble & we can guide you. This is better for learning than getting a complete code you don't understand

+4

Ok Sachet Bansod You have gotten really complicated with your attempt. There is no need to break down to ord's & then reconstruct to chr's. Remember the previous lessons prior to this challenge, & use the skillset shown to you. My suggestion: text = input() or "this is a test" # this will give you a default input that you can test you code against. 11 letters / 4 words. So first lets find number of words. text.split() will create a list of the words. Note* Read up about split() - very versatile Once you have a list, you can use len(list) to find the number of words Example: lst = text.split() print(len(lst)) Next post to continue PS: My dogging is woofing at me for attention

+4

Sachet Bansod Now to find number of letters Remember that " " is counted as a letter, just because we can't see it, does not mean the code ignores it. "this is a test" has 11 letters, but 14 characters, so we must filter the spaces out. letters =0 # a variable for i in text: # let's iterate through the sentence if i != " ": # if the iteration is not an empty space letters +=1 # we will count 1 to letters print(letters) # counts the number of letters.

+4

Sachet Bansod Now that you know number of letters and words, you should be able to assign these values to variables & resolve the problem. Let us know how you go

+4

Thanks Rik Wittkopp

+2

Here is my code: I didn't know what to do next: https://code.sololearn.com/cW3ul8IZ1V6h/?ref=app

+2

Hi Sachet Bansod this code would help you bro https://code.sololearn.com/ckXPpqg7R8rv/?ref=app

+1

You have a help me

+1

+1

+1

Thanks Abhishek Singh

0

0

Welcome Thanu Thanusha

0

Welcome Sachet Bansod