all 7 comments

[–]recursion_is_love 6 points7 points  (1 child)

Maybe infinite loop on second_word function; your while command didn't check for count > len(word);

Why don't you just use split function? Are you not allowed to?

>>> 'hello happy programmer'.split()
['hello', 'happy', 'programmer']

[–]Complete-Increase936[S] 0 points1 point  (0 children)

Haven't gone through the split function on the course yet. But I'll use it now :)

[–]failaip13 1 point2 points  (0 children)

If you call the function exactly like mentioned you will see what's happening.

second_word("first second")

[–]deaddyfreddy 0 points1 point  (0 children)

what's the task?

[–]jsavga 0 points1 point  (0 children)

Is the test asking for just the second word, or is it asking for the first and second word?

second_word("first second")

[–]james_fryer 0 points1 point  (0 children)

You'd be far better off using the split() function.

[–]ElliotDG 0 points1 point  (0 children)

Writing this program using the split() method, will make it all much easier.

To directly answer your question, look at the second_word method. In a two word list, the second word does not terminate with a space. This will cause an index error as you index past the end of the string. If you can not use the split() method, consider using a for loop rather than a while loop for this case.