+ 4
[SOLVED] Vowel counter code coach
You need to make a simple program that counts the number of vowels in a sentence. My code doesn't pass the last test and I can't figure out the reason. Ps: I tried to declare the sentence array with a length of 200 characters and it doesn't work. Another possible bug is the condition of the outer for that may be broken by a new line. But I don't think that Sololearn is doing these kind of tests on an 'easy" code coach. https://code.sololearn.com/cIZ3yZFBKyfa/?ref=app
9 Respuestas
+ 6
Don't see any problems here. Can it be that the sentence in the last test is larger than 200 characters? Is something about the sentence size told in the problem statement? Did you try to put for example 10**7 there? (both into array size and fgets) (sorry i cannot open the challenge because i am a greedy freeloader)
+ 5
Davide glad that you found the problem. It is a common case, when we do the change in one place and forget to do the corresponding change in another, so it's useful to write code in the way that every change has to be done only once (that is one of the reasons for "Don't Repeat Yourself" maxim). In this case you can either declare size of the array as a constant , and use the constant both in array declaration and fgets, or put sizeof(sentence) in fgets (for the last case you should be also careful of array to pointer decay, when size is lost, but here it is not a problem).
+ 4
Volodymyr Chelnokov OMG 😭😭😭
I am so dumb 😭😭😭
When I tried with 200 I haven't corrected the fgets 😭😭😭
I am so sorry 😔
Anyway thanks so much to you and everyone who tried to help me!🤗🤗🤗🤗🤗
+ 3
CHERIEF Houcine Abdelkader that's a lie. Don't lie to me 😔
In any case the increment is executed at the end of the loop
+ 3
NotAPythonNinja yes I had this idea as well, but checking the text of the problem I saw it specifies only aeiou in lowercase and uppercase
Thanks for trying anyway 😭🤗
+ 3
Volodymyr Chelnokov you are right, constants are a nice thing 🤗
+ 2
CHERIEF Houcine Abdelkader is there a reason for that?
+ 2
NotAPythonNinja I read it many times, it just says to count the vowels 😭 and that is what I do 😭