Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # Task: define a function that imitates "print". The function should
- # support such arguments as "sep", "end" and "file"
- def prnt(*args, sep=' ', end='\n', file=None):
- if "sys" not in dir():
- import sys
- if file:
- output_file = open(file, "w")
- else:
- output_file = sys.stdout
- for arg in args:
- if arg == args[-1]:
- output_file.write(arg)
- else:
- output_file.write(arg + sep)
- output_file.write(end)
- prnt("foo", "bar", "baz", sep = '_', end = "…\n", file="./test.txt")
- # foo_bar_baz…
- #
Add Comment
Please, Sign In to add comment