Answer to Question #313334 in Python for Chetan mirje

Question #313334

Given a list of different right and left foot shoes, write a python code to return the exact number of shoe pairs which can be formed from the given list. Also, return how many number of shoes of which foot are required to form pairs with the unpaired shoes.







Input Format







Input_list = ['R','L','L','R','R',R','R,'L']







Constraints







.







Output Format







Paired: 3







Unpaired: 2







Required left Shoes







Sample Input 0







8





L R L L R L R L





Sample Output 0







Paired: 3





Unpaired: 2





Required right shoes





Sample Input 1

1
Expert's answer
2022-03-18T02:26:22-0400
def num_list(list1):
    p = min(list1.count('R'), list1.count('L'))
    r = abs(list1.count('R')- list1.count('L'))
    return 'no of paired and unpaired shoes are {} and {}'.format(p,r)
num_list(['R','R','R', 'L', 'L'])

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