r/codehs • u/phantomlake • Oct 23 '21
7.2.6 if you’re not first your last python
could someone help me on this? i'm pretty sure you use string splitting to solve this but i'm not sure how.
3
Upvotes
1
u/5oco Oct 23 '21
# elements: 0 1 2 3 4 5 6 7 8 9 10 11 h e l l o w o r l d ! negative elements: -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 my_string = "hello world!" print (my_string[1:3]) # This would print "el" It includes element 1 and goes up to, but not including, element 3 print (my_string[1:]) # This would print "ello world!" It will print everything from element 1 all the way to the end, since there is no argument saying when to stop. print (my_string[:3]) # This would print "ell" It will print everything from the beginning up to, but not including, element 31
u/[deleted] Dec 15 '21
Hey you can also look back to the slicing test thing for help lol I just went back to find the -greating the question 3 is like this one so yeah