Answer to Question #228838 in Python for Jayanth

Question #228838
Reverse a string count the position of character same after reversed a string
Ex:abdrxxhga
Reversed string:aghxxrdba
Axxa are same position so count is 4
Count:4
1
Expert's answer
2021-08-24T16:42:44-0400
# Python 3.9.5

def enter_string():
    string = input('Enter string: ')
    return string

def reverse_string(string):
    reversed = string[::-1]
    i = 0
    count = 0
    for i in range(len(string)):
        if reversed[i].lower() == string[i].lower():
            count += 1
        i += 1
    return count

def main():
    string = enter_string()
    print(reverse_string(string))
    
if __name__ == '__main__':
    main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS