Aug-23-2019, 07:59 PM
(This post was last modified: Aug-23-2019, 10:10 PM by Drone4four.)
@ThomasL: You did a splendid job clarifying the syntax and semantics as you explain the index method.
@perfringo: I appreciate your sense of humour regarding the ValueError pun. Your use of type() and help() is instructive.
@newbieAuggie2019: That is certainly a creative way of replicating the same operation using the split() method instead of the index() method.
I set up a second string which is similar to the first but which this time is separated by a period “.” See here:
I feel like I have come to know slicing much better now. I appreciate the help from all of you. Thanks.
@perfringo: I appreciate your sense of humour regarding the ValueError pun. Your use of type() and help() is instructive.
@newbieAuggie2019: That is certainly a creative way of replicating the same operation using the split() method instead of the index() method.
I set up a second string which is similar to the first but which this time is separated by a period “.” See here:
>>> string_two = "happy.birthday" >>> string_two[string_two.index("."):] '.birthday'I shifted the casting method to the opposite side of the colon so that it grabs ‘birthday’ (instead of ‘happy’). However as you can see, the period is included. To omit the period, I just added “+1”. See here:
>>> string_two[string_two.index(".")+1:] 'birthday' >>>Hooray!
I feel like I have come to know slicing much better now. I appreciate the help from all of you. Thanks.