-1

ZyBooks Autograder Text

Code in ZyBooks

Hello,

I have my code written out which outputs identical to what ZyBooks is requesting, however in each of my outputs, I get a missing/incorrect newline error on my grader. I attched a picture to this post. I do not know why this is.

character = input()
list_of_words = input()

new_list_of_words = list_of_words.split()

string = ""

for word in new_list_of_words:
    for char in word:
        if character == char:
            string = string + word + ","
            break

print(string)

I tried changing the split function to new_string = string.split(" ") as well as playing around with the string concatenation inside the if block, however, none of it solved my problem.

Daniwave
  • 1
  • 2
  • It seems that your final string has extra whitespace. Try [stripping](https://docs.python.org/3/library/stdtypes.html#str.strip) your string of that whitespace. – Rojo Apr 07 '23 at 22:19
  • 1
    Please read [Why should I not upload images of code/data/errors?](https://meta.stackoverflow.com/q/285551/354577). Instead, format code as a [code block]. The easiest way to do this is to paste the code as text directly into your question, then select it and click the code block button. The same applies to problem text, except it should be a blockquote instead of a code block. – ChrisGPT was on strike Apr 08 '23 at 13:19

1 Answers1

-1

do print(string.strip(), end='')

it worked for me that way

plaswtf
  • 1
  • 1