Created
April 14, 2022 03:15
-
-
Save MrNyG25/c207882cfba82c00675be30aaf81dfc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SnakeUpperCaseTransformer(): | |
def __init__(self, string_param): | |
self.string_param = string_param | |
def showString(self): | |
print(self.string_param) | |
def convertToUpperCase(self): | |
rez = [] | |
for x in self.string_param.title(): | |
rez.append(x.replace("_", "")) | |
res = '' | |
for f in rez: | |
res+=f | |
self.string_param = res; | |
self.showString() | |
def converToSnakeCase(self): | |
rez = [] | |
index = 0; | |
for x in self.string_param: | |
if x.isupper(): | |
x = x.lower() | |
if index != 0: | |
rez.append('_') | |
rez.append(x) | |
index += 1 | |
res = '' | |
for f in rez: | |
res+=f | |
self.string_param = res; | |
self.showString() | |
while True: | |
print('\n********************word converter********************') | |
word = input('Enter your word: ') | |
instance = SnakeUpperCaseTransformer(word) | |
res = input('Do you want to convert it to snake case Y/n?') | |
if res.lower() == 'y': | |
print('******************Converted to snakecase******************\n') | |
instance.converToSnakeCase() | |
else: | |
print('******************Converted to uppercase******************\n') | |
instance.convertToUpperCase() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment