Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 62

Python Exercise Example 62

Python 100 Examples Python 100 Examples

**Problem:** Search for a string.

**Analysis:** None.

Program source code:


#!/usr/bin/python
# -*- coding: UTF-8 -*-

sStr1 = 'abcdefg'
sStr2 = 'cde'
print sStr1.find(sStr2)

The output of the above example is:


2

Python 100 Examples Python 100 Examples