pls make this python program I need it!
Q - You are given three strings- a string, first letter and second letter. Check if every instance of the first letter occurs before every instance of second letter. the string will be in lower case and will contain the first and second letter at least once.
string = "home"
first letter = "o"
second letter = "m"
True
**DON'T ANSWER IF YOU DIDN'T GET THE QUESTION OR DON'T KNOW THE ANSWER**
Answers
Answered by
0
Answer:
I DONT NO THE Answer Bro
Answered by
0
Answer:
test_string = "home"
first_letter = ord("o")
second_letter = ord("m")
sample = []
position_one = []
position_two = []
for x in test_string:
sample.append(x)
for index, value in enumerate(sample):
if ord(value) == first_letter:
position_one.append(index)
# print(position_one)
if ord(value) == second_letter:
position_two.append(index)
# print(position_two)
if position_one > position_two:
print("False")
else:
print("True")
Explanation:
read the code you will understand what i wrote
basically i converted the string to numbers and found the position and compared.
give thanks , brainliest if you liked my answer
Similar questions