Can anybody explain me this: s[81:67:-1]
When s is "this is me asking a question on stackoverflow.com and hoping to get an answer that will help me further"
            Asked
            
        
        
            Active
            
        
            Viewed 66 times
        
    -1
            
            
         
    
    
        grmbl
        
- 2,514
- 4
- 29
- 54
- 
                    2docs can — http://docs.python.org/2.3/whatsnew/section-slices.html – alexvassel Oct 09 '13 at 13:27
- 
                    Sorry for dup, I just did not know how to call this method. Now I know: "slice notation" – grmbl Oct 09 '13 at 13:36
2 Answers
2
            It is accessing string in reverse. From 81st character, till 67th character. The step value is -1. If you specify a positive value, you ll get nothing.
print s[81:67:-1]
print s[81:67:1]
Output
taht rewsna na
You can read more about it here. It is called slicing notation.
 
    
    
        thefourtheye
        
- 233,700
- 52
- 457
- 497
- 
                    
- 
                    thx @thefourtheye, will accept your answer when I can ^^ must say that python is beautiful, maybe I'll try & learn it. – grmbl Oct 09 '13 at 13:31
- 
                    
- 
                    
1
            
            
        You are accessing the element from position 81 to 67 but in reverse order (:-1 achieve this)
So, you are iterating over elements from position 67 to 81.
 
    
    
        user278064
        
- 9,982
- 1
- 33
- 46