Answer to Question #333047 in Python for sangeetha

Question #333047

neutralisation question input should be +------+--- --+-+-++-- and output should be 0-0-0-++0-


1
Expert's answer
2022-04-24T17:16:18-0400
data = input("Please enter your string: ").split(' ')
result = []
min_len = min(len(data[0]), len(data[1]))
for i in range(min_len):
    if data[0][i] != data[1][i]:
        result.append('0')
    else:
        if data[0][i] == '-':
            result.append('-')
        else:
            result.append('+')
print("Neutralisation:", end=' ')
for i in result:
    print(i, end='')

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