-
-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lesson Contribution - Swapping variables #883
Comments
I would like to contribute a pull request that closes this issue as part of my instructor training checkout. |
The original issue (raised by @klbarnes20) is, as I understand it, that swapping variables with the help of a temporary value temp = a
a = b
b = temp teaches a non-standard way of swapping variables in Python. The pythonic way of swapping variables is via the a, b = b, a idiom as explained in this popular Stack Overflow answer. This idiom in also part of the Additional Exercises but is not introduced in the core lessons. As I see it, the the core 'gotcha' in this exercise is failing to realise that local variables are created when a = 3
b = 7
def swap(a, b):
a, b = b, a
swap(a, b)
print(a, b) The idiomatic version of the This, and the swap idiom not being part of the core curriculum means that I am |
This discussion is similar to what was in 460. At that time it was decided not mention |
How about replacing the Switcheroo exercise with another that does not introduce the switching concept at all? Switching is not exactly a basic concept anyhow. |
I'm a member of The Carpentries staff and I'm submitting this issue on behalf of another member of the community. In most cases, I won't be able to follow up or provide more details other than what I'm providing below.
The text was updated successfully, but these errors were encountered: