Rdd.count() does not return any value

Entering anything but the exact solution does not pass the answer checking.

my code:

spoken_count = hamlet_spoken_lines.count()

expect:
381

got:
[undefined]

also tried:

spoken_count = 0 # shouldn't be necessary
spoken_count = hamlet_spoken_lines.count()
1 Like

Copied and ran your code

and it works.

You can try to execute the previous mission to ensure you have hamlet_spoken_lines loaded.

Agreeing with this issue. I had to use the answer with several seemingly unnecessary steps:

spoken_count = 0
spoken_101 = list()
spoken_count = hamlet_spoken_lines.count()
spoken_collect = hamlet_spoken_lines.collect()
spoken_101 = spoken_collect[100]

Why do these variables need to be defined in a single line before being assigned?

I had a similar problem in which the answer checking did not recognize the spoken_count variable, but I realized my answer was not right because of the assingment of the spoken_101 variable.

Wrong code:

spoken_count = hamlet_spoken_lines.count()
spoken_101 = hamlet_spoken_lines.collect()[101]

Right code:

spoken_count = hamlet_spoken_lines.count()
spoken_101 = hamlet_spoken_lines.collect()[100]

Even if the answer checking fails for spoken_count, check if spoken_101 is right.

The step of pre-defining the variables with:

spoken_count = 0
spoken_101 = list()

it is not necessary.

Regards.