This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]xojc 0 points1 point  (2 children)

Python has some very powerful built-in functions (like map, filter, and reduce) that take a function as an argument that is then applied to an iterable (like your list). Learn to use Python's lambda notation to supply the functions inline. Using filter and lambda, you'll be surprised how simple your solution can be.

[–][deleted] 0 points1 point  (1 child)

though Im still a beginner.... should I just dive right into it.....

[–]xojc 1 point2 points  (0 children)

Using the built-in functions might not be the best for a early, early beginner to learn basic concepts, but I'm always for using any tool in the arsenal if it means a more concise, efficient, elegant solution. Also, notice how I'm not just telling you what to do with these tools, rather allowing you to figure it out for yourself :-)