Hey guys,

In Java, there is a method called substring, but what substitute does it have in Python, or do I have to explicitly do it like:

s=raw_input("Enter a sentence: ")
s2=""
a=0
b=0
for a in s:
    if(a==' '):
       s2= s[b:a]
        b=a
    a+=1

Thanks guys!

The equivalent device in python is slicing:

>>> my_text = 'Rajesh Kumar'
>>> my_text[3:]
'esh Kumar'
>>> my_text[1:2]
'a'
>>>

This example is analogous to the example on this page, which gives example usage of Java substring.