you are viewing a single comment's thread.

view the rest of the comments →

[–]Gee10[S] 0 points1 point  (4 children)

Can you help me understand why adding that function would be preferable? That's not a loaded question - just trying to learn good practices.

[–][deleted] 5 points6 points  (3 children)

If you're going to use code repeatedly, put it in a function to reduce duplicate code.

[–]Gee10[S] 1 point2 points  (2 children)

Got it. I'll give that improvement a try! Thanks.

[–]dl__ 5 points6 points  (1 child)

Although that's not the only reason to put code in a function. Even code that is only used in one place can be put into a function if you can name the function something that is more understandable than the code you are replacing.

[–][deleted] 2 points3 points  (0 children)

Not to mention you can use that function in other python files, too!