Dealing with strings in Python is very simple: you can search, replace, change character case, and perform other manipulations with ease:
To search for a string, you can use the find method like this:
#!/usr/bin/python3str = "Welcome to Python scripting world"print(str.find("scripting"))
The string count in Python starts from zero too, so the position of the word scripting is at 18.
You can get a specific substring using square brackets like this:
#!/usr/bin/python3str = "Welcome to Python scripting world"print(str[:2]) # Get the first 2 letters (zero based)print(str[2:]) # Start from the second letterprint(str[3:5]) # ...