Python program to print the index of the character in a string?

x=str(input(“Enter string”))
for i in range (0,len(x)):
i+=0
print(" “, x[i] ,” ",i)

1 Like

@mick4mayank

Correct, keep it up :slightly_smiling_face:.

1 Like

thnks, keep posting more …

1 Like

@mick4mayank

Sure will put more questions.

def change_char(str1):
2 char = str1[0]
3 str1 = str1.replace(char, ‘$’)
4 str1 = char + str1[1:]
5
6 return str1
7
8 print(change_char(‘restart’))

def findLen( str ):

counter = 0

for i in str :

counter + = 1

return counter

str = "geeks"

print (findLen( str ))

2 Likes

Good one
Keep practicing

@prabhudevaraj11

Correct, keep it up.

1 Like

def findLen( str ):

counter = 0

for i in str :

counter + = 1

return counter

str = "geeks"

print (findLen( str ))

@prabhudevaraj11

Correct, keep it up.