+ 1
How to answer Sololearn Code Coach challenge?
I just tried the code coach for the first time, and picked up average word length or so def average_length(str): words = str.split(" ") total_lengths, total_words = 0, 0 for word in words: if(word.isalnum()): total_lengths += len(word) total_words += 1 return total_lengths // total_words + (total_lengths % total_words > 0) Yet it says my code produces no output?? What's the format for the challenges?
4 odpowiedzi
+ 3
Hi! When the program needs inputs, you use input(). When the program needs an output, you use print(). If the result is processed inside a function, you have to run the function:
def myFunction(arg):
….
return res
s = input()
result = myFunction(s)
print(result)
+ 2
ImaleeqB
It's not up to Sololearn to call your function, it is up to you to write a code which calls the function.
That is how coding works.
+ 1
Rik Wittkopp
It's up to Sololearn to pass me the arg. All things being equal the standard input is a prompt box displayed when i click run. I never knew it would be changed in certain scenario such as this. I think Per Bratthammar 's answer was just on point
and the line that's how coding works lol, rather how Sololearn challenge works.
write a function that does this and this is a valid question, only if that isn't coding
0
I think sololearn should call my function with the input