Answer to Question #215373 in Python for santu1

Question #215373

Write an algorithm for the network administrator to help him find number of data characters that do not change position even after the data stream is reversed


1
Expert's answer
2021-07-12T03:09:27-0400
#The algorithm is very simple and it is clearly demostrated below using an example




myString = 'adadda' #Using this set of characters as an example
data = list(myString) #Putting the characters in a list


string_reversed = list(reversed(myString)) #Reversing the list and storing it in a variables


st = "" #A string to store the characters that do not change the position
for row in string_reversed: #Iterating over the original characters
    for i in data: #Iterating over the characters after reversal
    #Checking if the position of character has not changed
        if string_reversed.index(row) == data.index(row): 
            st += i 
           


print(set(list(st))) #Printing the final list of characters that do not change the position       
    

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