We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi everyone! Here’s my solution to this exercise. I’m currently having an issue with Test Case 2. When I run the code, it seems to produce the expected result, but it’s still not passing. Does anyone have an idea of what might be going on?
importreimportsys# Enter your code here. Read input from STDIN. Print output to STDOUTdefsplit_word(word):word=re.sub(r'\(\)$',r'',word)word=re.sub(r'(?<!^)([A-Z])',r'\1',word)word=word.lower()print(word)defcombine_word(word,word_type):word=word.strip()ifword_type=='M':word=word+"()"elifword_type=='C':word=word.capitalize()word=re.sub(r'\s([a-z])',lambdax:x.group(1).upper(),word)print(word)defcamelCase(action,word_type,word):ifaction=='S':split_word(word)elifaction=='C':combine_word(word,word_type)input_lines=sys.stdin.read().strip().split('\n')forlineininput_lines:action,word_type,word=line.split(';')camelCase(action,word_type,word)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Camel Case 4
You are viewing a single comment's thread. Return to all comments →
Hi everyone! Here’s my solution to this exercise. I’m currently having an issue with Test Case 2. When I run the code, it seems to produce the expected result, but it’s still not passing. Does anyone have an idea of what might be going on?