write a python program to input a string and from given string find the occurrence of the first alphabet of the string
Ans fast
First correct answer would be marked as brainlist
Answers
Answered by
8
string = input("Enter a string: ")
ch = string[0]
count = 0
for i in string:
if i == ch:
count = count + 1
print(ch, "appears in", string, count, "times.")
The first character can be obtained by using positive indexing.
You then start a loop, that traverses through the string and checks if the first character is present in the string or not and counts the number of times it occurs in it.
Attachments:
Answered by
2
Answer:
string = input("Please enter your own String : ")
char = input("Please enter your own Character : ")
count = 0
for i in range(len(string)):
if(string[i] == char):
count = count + 1
print("The total Number of Times ", char, " has Occurred = " , count)
Similar questions
Social Sciences,
5 months ago
English,
5 months ago
Math,
10 months ago
Science,
10 months ago
Social Sciences,
1 year ago
Biology,
1 year ago