Answer to Question #164741 in Python for prathyusha

Question #164741

Given a string of length N, made up of only uppercase characters 'R' and 'G', where 'R' stands for Red and 'G' stands for Green. Find out the minimum number of characters you need to change to make the whole string of the same colour.


1
Expert's answer
2021-02-18T14:38:14-0500
s = str(input("Enter the string: "))
count = 0
s1 = s.count('R')
s2 = s.count('G')
if s1>s2:
    count = s2
else:
    count = s1
print(count)

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