PythiloLesson 2 of 30 · progress kept in this browser

Printing output

print takes any number of values, turns each one into text with str, and writes them with a space between and a newline at the end. Two keyword arguments change that.

print("a", 1, True)       # a 1 True
print("a", "b", sep="-")  # a-b
print("same", end="")
print(" line")            # same line
nums = [1, 2, 3]
print(*nums, sep=", ")    # 1, 2, 3
print()                   # empty line
  • sep goes between the values. The default is one space.
  • end goes after the last value. The default is "\n", a newline.
  • *nums spreads a list into separate arguments, so each item is printed on its own terms.
Your task

Write print_row(values) that prints the values on one line separated by " | ". Write print_list(words) that prints the words on one line separated by ", ", ending with ".\n" instead of a plain newline.