Search code examples
pythonpseudocode

How to represents initialization of empty list in python into pseudocode


I want to ask how to represents initialization of empty list into pseudocode, my code is following below:

cat1 = []
cat2 = []
cat3 = []
cat4 = []
cat5 = []
cat6 = []
cat7 = []

In here I want to ask how to represent those things into good looking and simple pseudocode.


Solution

  • If I felt the need to include these in pseudocode, I would probably use the word "SET" or "ASSIGN". For example:

    "SET cat5 equal to EMPTY LIST"
    "ASSIGN EMPTY LIST to cat5"

    Also, the variable names should be replaced with a better description of what they will eventually contain, rather than the variable names themselves. I just couldn't do it in this example because I don't know what they will be.

    In response to the comments you left on both answers: I wouldn't worry about the repetition. The point of pseudocode is to clearly explain an algorithm, and if it needs to be long to do that well, so be it. The only way to shorten it that I can think of would be to use "FOR EACH list of < x >", but that may imply loops to some readers, and will make it harder to tell which list you're referring to later on in your pseudocode, so I don't think I'd recommend it. You're probably better off just letting your pseudocode be long and explicit, rather than sacrificing clarity for brevity.