A good first principle of software development is to try to do as little as possible at a time.
So! Part 1 of the task manager is going to be very, very simple, because the goal right now is for you to have somewhere to write Python code and execute it. I am not the best person to explain how to do this! Here are some resources:
If you have access to a standard terminal (either on a Mac or Linux machine, or on Windows via WSL), you can do something like:
nano main.py python3 main.py
(You'll be able to do this after you type in the code below and save it in the main.py
file.)
Note that any error message you see while you install Python, try to find files in the terminal, and so on is likely to have a zillion answers discoverable by means of search engines. Googling error messages is an important programming skill.
For now this is completely agnostic about how you're editing a file and running it. We'll store the code for our task manager in a file called main.py
:
tasks = [
"Move shelves",
"Move air conditioners",
"Empty dishwasher",
"Take vitamins"
]
for task in tasks:
print(task)
(Put that code in a file called main.py
.)
Here are some things to know about this code:
tasks
is a variable; specifically, it's a list. What we've done is to create a list of four elements, each of which is a string, and assign it to a variable called "tasks."for task in tasks
says, roughly: "Go through each of the elements of tasks
(there are four of them) and assign each of them in turn to the variable named task
; each time you do that, also execute the indented code below." If this is unfamiliar to you, the thing to read about is iterators and for-loops.And here are some things to know about studying this code: 1. If it doesn't make sense immediately, that's OK. I went through that quickly because there are so many beginning Python resources elsewhere. (Aren't you glad you're reading this and not a book?) 1. If this is all very familiar to you, OK! We'll hit advanced topics quickly. (But not "advanced" in the sense that the uninitiated won't be able to understand them.)
When you run the code, you should see:
Move shelves
Move air conditioners
Empty dishwasher
Take vitamins
Next post: Python task manager from scratch, part 2: First cleanup!