Computer Science, asked by bhagyeshsyllshare, 1 month ago

score: 24 Question 3 Max. score: 20.00 Number of likes and dislikes + 2.0 Your friend and you made a list of topics and both of them voted if they like or dislike the topic. They wrote 0 to denote dislike and 1 to denote like. They asked you to count the number of topics that both like or both dislike. + 2.0 Input format • The first line contains a string, A, denoting Bob's likes and dislikes. • The second line contains a string, P, denoting Alice's likes and dislikes. Output format 20.0 Print the number of topics both, Bob and Alice, like or dislike. ​

Answers

Answered by poojan
9

Language used: Python Programming

Program:

#Enter Bob's choices

bob = input()

#Enter Alice's choices

alice = input()

#Make sure that both strings are of the same size.

#Iterating over the strings by comparing the choices of each index in 2 strings with each other. If they are the same, increment the common value by 1.

common = 0

for i in range(len(bob)):

   if bob[i] == alice[i]:

       common = common + 1

print(common)

Input 1:

010101

101101

Output 1:

3

Input 2:

111111

000000

Output 1:

0

Learn more:

1) Printing all the palindromes formed by a palindrome word

brainly.in/question/19151384

2) Indentation is must in python. Know more about it at:

brainly.in/question/17731168

Attachments:
Similar questions