Python Tutorial | Python Strings 7

Python program to search a character within a string?

n="computer"
ch=input("Enter character to search ")
z=0
for i in n:
    if(i==ch):
        z=1
        break
if(z==1):
    print("character is present")
else:
    print("character is not present")
    
    

Output:

Enter character to search k
character is not present
>>>

Enter character to search m
character is present
>>>

Python Basic Programming Tutorial

Python Introduction     Getting started in Python Programming      Python propgramming fundamentals     Python Operators    Python If Condition     Python for loop    Python range construct      Python While loop    break and continue statements     Different looping techniques     Python List     Python String     Python Functions    Python Inbuilt Functions     Python Recursion     Using Python Library     Python Tuples     Python Dictionary     Python Sets     Python Strings     Python Exception Handling     Python Data File Handling

Visitor Counter

0161189