-3

So I have this piece of code here

#inside of a repeating "while loop"
      print(even,flush=True, end=inbetween) #inbetween is what's between each number. (space, new line, etc.)
      even=even+2

Which prints out a sequence of even numbers in my number generator (https://github.com/JasonDerulo1259/JasonsGenerator)

The issue I have with it is that When I do f.write to write the result It says that I am not allowed to write something with multiple arguements. What is the work-around for this?

(here's the syntax error that shows)

File "main.py", line 34, in massprint
    f.write(even,flush=True, end=inbetween)
TypeError: write() takes no keyword arguments

Also, If i try put even,flush=True, end=inbetween inside of a variable, I get this syntax error no matter how I change it.

  File "main.py", line 32
    placeholdervar=[even,flush=True, end=inbetween]
                              ^
SyntaxError: invalid syntax

1 Answers1

0

"Just do print(even,flush=True, end=inbetween, file=f)

– Tomerikoo"

And to print to file and console. Just add another without 'file=f'

  • 1
    This is the first answer in the linked duplicate at the top of this page. There is no need to repeat answers. Users arriving here will see the link above and get the answer – Tomerikoo Dec 24 '20 at 19:07