Computer Science, asked by rekha1974thapa, 8 months ago

write a program to accept a word and check the string for the presence of consecutive letters if two letters are consecutive in any position it prints it is a magic string otherwise it prints not a magic string

please write the whole program!!

Help out!!​

Answers

Answered by valeriy69
1

def detect_magic_string(string):

magic_counter = 0

for k, v in zip(string, string[1:]):

if ord(v) - ord(k) == 1:

magic_counter += 1

if magic_counter > 0:

print("it is a magic string")

else:

print("not a magic string")

if __name__ == "__main__":

string = input("Enter string: ")

detect_magic_string(string)

#above program is in python 3

Similar questions