Decode School

Decode School - The School for Problem Solvers

Welcome to my blog. Subscribe and get my latest blog post in your inbox.

find a character in a String Python

python program to get a String and a character then find where the character occurred first in the string.

Sample Input 1 :

Hello l

Sample Output 1 :


Program or Solution

s=input("Enter a String:")
c=input("Enter a Character:")

for i in range(0,len(s)):
    print("Not Found")


Program Explanation

Visit each location in string s one by one for i in range(0,len(s)): if character c is found, return th location i