Print the content of a file

Created by Julien Palard

Warning

It's better to try this exercise with your own installation of Python, on your computer. Learn how for Mac OSX or Windows.

Write a program which reads and prints the content of the words.txt file. That's all. I'll put the file is in the same directory as your code, so no absolute path required, just "words.txt" (or "./words.txt").

Advice

You can use the open builtin function or pathlib.

If you're running this exercise on your computer, with your own Python, you can try this exercise by manually creating a words.txt file, in the same directory than your Python file, write some words in it.

My test code will create the file before running your code, don't worry, don't write code to create the file, don't write code to write in the file, just read it.

There's no corrections yet, hit the `Submit` button to send your code to the correction bot.

Keyboard shortcuts:

  • Ctrl-Enter: Send your code to the correction bot.
  • Escape: Get back to the instructions tab.

See solutions