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.
Enter your code here. Read input from STDIN. Print output to STDOUT
import sys
import re
for line in sys.stdin:
line = line.strip() # Get rid of trailing spaces, newlines, etc.
operation, object_type, words = line.split(';')
if operation == 'S':
words = words[:-2] if object_type == 'M' else words
words = re.split('(?=[A-Z])', words)
if object_type == 'C':
words.remove('')
for i in range(len(words)):
words[i] = words[i].lower()
print(*words, sep=' ')
else: # operation == 'C'
words = words.split()
for i in range(0 if object_type == 'C' else 1, len(words)):
words[i] = words[i][0].upper() + words[i][1:]
combined = ''.join(words)
if object_type == 'M':
combined += '()'
print(combined)
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 →
Enter your code here. Read input from STDIN. Print output to STDOUT
import sys import re
for line in sys.stdin: line = line.strip() # Get rid of trailing spaces, newlines, etc. operation, object_type, words = line.split(';')