Fixing confusion for indexing python dictionaries#370
Fixing confusion for indexing python dictionaries#370Benfeitas wants to merge 1 commit intodatacarpentry:gh-pagesfrom Benfeitas:patch-1
Conversation
|
Not sure if there is a confusion actually. |
|
@pr4deepr I agree with you. However, learners may think that indexing may be done in terms of key position and key order is not guaranteed to be preserved - aside from insertion order. For the lesson at hand, I think that #360 (comment) makes sense and is simpler if we just have it as text. |
|
Thanks @RBenRocks . Agree with that, but I think this bit should not be modified, but you can add these changes later on instead? |
|
I've been thinking about this PR and issue #360 and couldn't understand their relationship because the issue says:
and this PR changes values and, moreover, the very first dictionary introduced does not actually use numeric keys. Now I understand that we're talking about the I support this change because we shouldn't be using numeric keys with dictionaries, actually: a = {1 : '2'}
print(a)
a[1.0] = '3'
print(a)
a[True] = '4'
print(a)And we should definitely fix that Also, statement |
|
Thanks for clarifying this. |
| > | ||
| > 1. First, print the value of the `rev` dictionary to the screen. | ||
| > 2. Reassign the value that corresponds to the key `2` so that it no longer | ||
| > 2. Reassign the value that corresponds to the key `second` so that it no longer |
There was a problem hiding this comment.
In this new set of assignments, I do agree that using strings is a little more explicit. But I think we should make it clear that dictionaries are not only for strings. Perhaps we should have them reassign the value of second to the numeral 2 instead of apple-sauce.
|
I like this. I've made one comment on the challenge. If you agree, go ahead and add that to this PR, if not just let me know. |
| > 1. First, print the value of the `rev` dictionary to the screen. | ||
| > 2. Reassign the value that corresponds to the key `2` so that it no longer | ||
| > 2. Reassign the value that corresponds to the key `second` so that it no longer | ||
| > reads "two" but instead "apple-sauce". |
There was a problem hiding this comment.
| > reads "two" but instead "apple-sauce". | |
| > reads "two" but instead "2". |
There was a problem hiding this comment.
I went ahead and added my comment as a suggestion, since you seem on board, @RBenRocks. If you click the "Commit suggestion" box, it'll add my change to your PR. Then I'll merge and we're done!
|
A lot of things have changed since we discussed this PR. |
|
Superseded by #445 |
See #360