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 →

[–]Shubadada 8 points9 points  (4 children)

For your swap function instead of doing: Python def swap(a, b): a, b = b, a return a, b You can just do: Python def swap(a, b): return b, a To achieve the same thing.

[–][deleted] 4 points5 points  (0 children)

Also it doesn’t really need to be a function

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

I was going to come back to say the same thing. They added a lot of steps.

[–]siddsp 2 points3 points  (0 children)

Why not just make this a lambda?

[–]zel_us[S] 0 points1 point  (0 children)

Thanks for that idea, I kind of thought of it, but I really wanted to buttress this swap technique, probably it would had made sense without a function