I want to know how I can write result in the file. This is my homework. I hope someone help me.
Thank you.
Asked
Active
Viewed 46 times
-3

김태인
- 1
- 1
-
Please have a look at [the documentation for the `print` function](https://docs.python.org/3.8/library/functions.html#print) and the `file` argument in particular. – ForceBru May 20 '20 at 12:21
-
2Welcome to [so]! Paste your code directly to your question and apply [code formatting](https://stackoverflow.com/editing-help#code). [An image of your code is not helpful](http://idownvotedbecau.se/imageofcode) – Melebius May 20 '20 at 12:25
-
1Does this answer your question? [How to redirect 'print' output to a file using python?](https://stackoverflow.com/questions/7152762/how-to-redirect-print-output-to-a-file-using-python) – Tomerikoo May 20 '20 at 12:27
1 Answers
1
Do not use print, instead assign that to a variable
text = 'something {} here'.format(where)
print(text) # if you still want to print
f.write(text)

Cory Kramer
- 114,268
- 16
- 167
- 218