I was looking for an algorithm to replace some content inside a list with another. For instance, changing all the '0' with 'X'.
I found this piece of code, which works:
list = ['X' if coord == '0' else coord for coord in printready]
What I would like to know is exactly why this works (I understand the logic in the code, just not why the compiler accepts this.)
I'm also struggling with inserting an "elif" condition in there (for the sake of the argument, changing '1' with 'Y').
This is probably thoroughly documented, but I have no idea on what this thing is called.