0

I was trying to run my code through the online textbook we have and though it mostly have the same output it's telling me there is a new line that's not supposed to be there and I don't know how to get rid of it.

this is what i wrote:

user_input = input()
user_split = user_input.split()
int_input = [int(i) for i in user_split]
non_negs = [i for i in int_input if i>=0]
non_negs.sort()
non_negs_str = [str(i) for i in non_negs]

desired_output = (' '.join(non_negs_str))
print(f'{desired_output}')

i also tried:

print(f'{desired_output} ') 

however it still shows i am printing a new line.enter image description here

  • `print(desired_output, end="")` or `print(desired_output + " ", end="")` as seen in the duplicate, but that’s a really questionable choice by the online textbook. (If it is expecting a space, maybe the intended solution is `print(i, end=" ")` in a loop, but… yeah. Your original output format is better.) – Ry- Nov 09 '22 at 06:46

0 Answers0