One Color in Python

Problem Statement:

In One Color in Python, we are given a string having only G and R letters only. G represents green and R represents Red color. We need to find the minimum number of G or R letters to make a new string having only G or R letters.

Code for One Color in Python:

color = input("Enter colorful string: ")
r = 0
g = 0
for i in color:
    if i=='R':
        r += 1
    else:
        g += 1
if r>=g:
    print('Minimum ', g, 'G letters are required')
else:
    print('Minimum ', r, 'R letters are required')

Output:

One Color in Python

Also Read:

Share:

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@violet-cat-415996.hostingersite.com Thank you