Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' >>> x[2:-2] 'llo Worl' 

Python calls this concept "slicing" and it works on more than just strings. Take a look herehere for a comprehensive introduction.

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' >>> x[2:-2] 'llo Worl' 

Python calls this concept "slicing" and it works on more than just strings. Take a look here for a comprehensive introduction.

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' >>> x[2:-2] 'llo Worl' 

Python calls this concept "slicing" and it works on more than just strings. Take a look here for a comprehensive introduction.

Add one additional example (the one I was looking for when I came here)
Source Link
>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' >>> x[2:-2] 'llo Worl' 

Python calls this concept "slicing" and it works on more than just strings. Take a look here for a comprehensive introduction.

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' 

Python calls this concept "slicing" and it works on more than just strings. Take a look here for a comprehensive introduction.

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' >>> x[2:-2] 'llo Worl' 

Python calls this concept "slicing" and it works on more than just strings. Take a look here for a comprehensive introduction.

added complementary link
Source Link
phant0m
  • 17k
  • 6
  • 52
  • 84
>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' 

Python calls this concept "slicing" and it works on more than just strings. Take a look here for a comprehensive introduction.

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' 
>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!' 

Python calls this concept "slicing" and it works on more than just strings. Take a look here for a comprehensive introduction.

answers to cases in the OP edit
Source Link
Pete Kirkham
  • 49.5k
  • 5
  • 96
  • 176
Loading
Source Link
Paolo Bergantino
  • 489.9k
  • 83
  • 524
  • 437
Loading