Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A student saves a program as my first program.py.txt, opens a terminal, types python my first program.py.txt, and gets an error. List all the things that are wrong with the name, and write a good name for the file.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Check the name against the rules of the lesson.
.txt. The file is a text file. The name must end in .py.python my first program.py looks like four words. Use an underscore: my_first_program.py..py.txt is a trap: the name looks like a Python file, but it ends in .txt.A good name. my_first_program.py, with small letters, underscores and the ending .py.
Check. Run python my_first_program.py from the folder of the file. The terminal then gets one word after python.
Answer: The ending is .txt, and the name has spaces. Use my_first_program.py.
Log in to join the discussion.
Loading…