-
-
Notifications
You must be signed in to change notification settings - Fork 780
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
update explanation of the slicing element string #818
update explanation of the slicing element string #818
Conversation
To slice the last three characters, one should use element[-3 : ], which might be a more universal way for any string with length >=3. Using element[3:6] refers to the 4th to the 6th characters by its literal meaning.
Hi @zhaophotonicslab, congratulations on opening your first Software Carpentry PR! You make a valid point here that if you want a general slice of the last 3 characters of a string you should use |
Dear Lauren,
Thanks for your prompt response. It is a good idea to put it as an exercise to the Challenge. I agree with you that introducing negative indexing may bring confusions or take more time to explain to students.
…________________________________
From: Lauren Ko <notifications@github.com>
Sent: Thursday, April 2, 2020 8:17 AM
To: swcarpentry/python-novice-inflammation <python-novice-inflammation@noreply.github.com>
Cc: zhaophotonicslab <zhao.qiancheng@outlook.com>; Mention <mention@noreply.github.com>
Subject: Re: [swcarpentry/python-novice-inflammation] update explanation of the slicing element string (#818)
Hi @zhaophotonicslab<https://github.com/zhaophotonicslab>, congratulations on opening your first Software Carpentry PR! You make a valid point here that if you want a general slice of the last 3 characters of a string you should use [-3 : ]. However, I think where you are making this change, the negative indexing has not yet been introduced. Since in the case of "oxygen", element[3:6] does also give you the last three characters, I suggest we leave that as is, and then add a final part to the Challenge (after the solution for explaining what element[1:-1] does) that asks something like "How can we rewrite the slice for getting the last three characters of element, so that it works on any character string of at least three characters"?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#818 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AORJ7NDPWK2QA3Z4DNCKDYDRKSUBRANCNFSM4LZ62PAQ>.
|
Hi @zhaophotonicslab, since negative indexing is brought up in the Challenge shortly after where you have made an edit, after that point, we have a good opportunity to show the way you suggest of getting the last three characters. Would you like to modify this Pull Request to change line 508 back to what it was then ask "How can we rewrite the slice for getting the last three characters of |
Revert the Line 508 to previous way of slicing the last three characters of element Add negative index to slice the last three characters of element in the challenge part
Hi Lauren,
Thanks for the suggestions. I agree it is better to put it in the challenge part. I have modified my branch as suggested. Do I need to create a new pull request?
The commit ID to my own branch is 1334999
I might have also accidently committed to swcarpentry gh-page branch. If I did, please ignore that.
Thanks again for your response.
From: Lauren Ko <notifications@github.com>
Sent: Friday, April 3, 2020 8:26 AM
To: swcarpentry/python-novice-inflammation <python-novice-inflammation@noreply.github.com>
Cc: zhaophotonicslab <zhao.qiancheng@outlook.com>; Mention <mention@noreply.github.com>
Subject: Re: [swcarpentry/python-novice-inflammation] update explanation of the slicing element string (#818)
Hi @zhaophotonicslab<https://github.com/zhaophotonicslab>, since negative indexing is brought up in the Challenge shortly after where you have made an edit, after that point, we have a good opportunity to show the way you suggest of getting the last three characters. Would you like to modify this Pull Request to change line 508 back to what it was then ask "How can we rewrite the slice for getting the last three characters of element, so it will work on any character string at least three characters in length"? around line 550?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#818 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AORJ7NBZ5AOME27X3FWJJR3RKX5ZJANCNFSM4LZ62PAQ>.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhaophotonicslab thank you so much for the quick followup and changes! There is no need to open a new pull request. This one will be fine to continue with. These changes look good but need a few minor changes before we can merge them.
add > symbol to fix syntax errors Rephrase questions in Line 550 and Line 551
Hi @IDKo,
Thanks for pointing out the errors. I have fixed the syntax errors as suggested.
From: Lauren Ko <notifications@github.com>
Sent: Friday, April 3, 2020 10:15 AM
To: swcarpentry/python-novice-inflammation <python-novice-inflammation@noreply.github.com>
Cc: zhaophotonicslab <zhao.qiancheng@outlook.com>; Mention <mention@noreply.github.com>
Subject: Re: [swcarpentry/python-novice-inflammation] update explanation of the slicing element string (#818)
@ldko requested changes on this pull request.
@zhaophotonicslab<https://github.com/zhaophotonicslab> thank you so much for the quick followup and changes! There is no need to open a new pull request. This one will be fine to continue with. These changes look good but need a few minor changes before we can merge them.
________________________________
In _episodes/02-numpy.md<#818 (comment)>:
@@ -546,6 +546,20 @@ which is the average inflammation per patient across all days.
> Creates a substring from index 1 up to (not including) the final index,
> effectively removing the first and last letters from 'oxygen'
{: .solution}
+>
+> How can we rewrite the slice for getting the last three characters of `element` does,
+> so it will work on any character string at least three characters in length.
+>
+> > ## Solution
+> > ~~~
+> > print('last three characters:', element[-3:])
+> ~~~
+> {: .language-python}
There is a slight syntax error here that is causing a failed check on the Pull Request. I think we can fix it with another greater than symbol on the two above lines:
> ~~~
> {: .language-python}
________________________________
In _episodes/02-numpy.md<#818 (comment)>:
@@ -546,6 +546,20 @@ which is the average inflammation per patient across all days.
> Creates a substring from index 1 up to (not including) the final index,
> effectively removing the first and last letters from 'oxygen'
{: .solution}
+>
+> How can we rewrite the slice for getting the last three characters of `element` does,
+> so it will work on any character string at least three characters in length.
Can you remove the word "does" on line 550 and change the period (.) to a question mark (?) at the end of line 551?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#818 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AORJ7NDP3Y622ZKALPW53YLRKYKSTANCNFSM4LZ62PAQ>.
|
Add more test examples of the challenge of last three character slicing. Add 'carpentry', 'clone', 'hi'
minor fix on the output of last three character slicing
That’s a good idea. Thanks to @maxim-belkin and @IDKo. The changes have been made.
From: Lauren Ko <notifications@github.com>
Sent: Friday, April 3, 2020 11:08 AM
To: swcarpentry/python-novice-inflammation <python-novice-inflammation@noreply.github.com>
Cc: zhaophotonicslab <zhao.qiancheng@outlook.com>; Mention <mention@noreply.github.com>
Subject: Re: [swcarpentry/python-novice-inflammation] update explanation of the slicing element string (#818)
@ldko commented on this pull request.
________________________________
In _episodes/02-numpy.md<#818 (comment)>:
@@ -546,6 +546,20 @@ which is the average inflammation per patient across all days.
> Creates a substring from index 1 up to (not including) the final index,
> effectively removing the first and last letters from 'oxygen'
{: .solution}
+>
+> How can we rewrite the slice for getting the last three characters of `element`,
+> so it will work on any character string at least three characters in length?
I think that change is fine to make. It might be nice having hi as an example, since it will show learners that it doesn't error to take a slice bigger than the string.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#818 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AORJ7NHSLJ3YXR5ZZNEUHSLRKYQYBANCNFSM4LZ62PAQ>.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great! Thanks very much, @zhaophotonicslab !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you @zhaophotonicslab! Great job, Lauren!
To slice the last three characters, one should use element[-3 : ], which might be a more universal way for any string with length >=3.
Using element[3:6] refers to the 4th to the 6th characters by its literal meaning.
Please delete this line and the text below before submitting your contribution.
Thanks for contributing! If this contribution is for instructor training, please send an email to checkout@carpentries.org with a link to this contribution so we can record your progress. You’ve completed your contribution step for instructor checkout just by submitting this contribution.
Please keep in mind that lesson maintainers are volunteers and it may be some time before they can respond to your contribution. Although not all contributions can be incorporated into the lesson materials, we appreciate your time and effort to improve the curriculum. If you have any questions about the lesson maintenance process or would like to volunteer your time as a contribution reviewer, please contact The Carpentries Team at team@carpentries.org.