Since the question specifically mentions that it should be in a loop (perhaps there is further processing that needs to be done that was taken out), here's what that would look like (modifying @Andrej Kesely's strong approach)
sort_ = { str(4213) : ("STEM Center",0), str(4201) : ("Foundations Lab",1), str(4204) : ("CS Lab",2), str(4218) : ("Workshop Room",3), str(4205) : ("Tiled Room",4), "Out" : ("Outside",5) }
result = []
for key, (name, count) in sort_.items():
result.append((key, name, count))
I renamed sort
to sort_
. Even though it isn't in this namespace (sort
is a method on lists), I don't like using key words.
[('4213', 'STEM Center', 0),
('4201', 'Foundations Lab', 1),
('4204', 'CS Lab', 2),
('4218', 'Workshop Room', 3),
('4205', 'Tiled Room', 4),
('Out', 'Outside', 5)]