Skip to content
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

Use list instead of tuple in variable swapping exercise #346

Conversation

tv3141
Copy link

@tv3141 tv3141 commented Jan 15, 2017

right, left = left, right
"...we pack right and left into a tuple and then unpack it again into left
and right."

This example for variable value swapping introduces three new concepts:
1. the tuple data type
2. special tuple syntax, omitting parentheses
3. container unpacking in an assignment

I think using a list is much clearer, and only introduces the concept of
container unpacking.

right, left = [left, right]

> right, left = left, right
> "...we pack right and left into a tuple and then unpack it again into left
> and right."

This example for variable value swapping introduces three new concepts:
    1. the tuple data type
    2. special tuple syntax, omitting parentheses
    3. container unpacking in an assignment

I think using a list is much clearer, and only introduces the concept of
container unpacking.

right, left = [left, right]
@valentina-s
Copy link
Contributor

Thanks, I agree that using a list is more clear (I think these were remnants from the old lessons which introduced tuples).

@valentina-s valentina-s merged commit 7b04c07 into swcarpentry:gh-pages Feb 3, 2017
rgaiacs pushed a commit to rgaiacs/swc-python-novice-inflammation that referenced this pull request May 6, 2017
Update lesson objectives of lesson on them
zkamvar pushed a commit that referenced this pull request Apr 21, 2023
…list

Use list instead of tuple in variable swapping exercise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants