We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c17e03e commit 6729904Copy full SHA for 6729904
exam1/cases.py
@@ -13,12 +13,24 @@
13
variable in camel case and outputs the corresponding name in snake case.
14
Assume that the user’s input will indeed be in camel case.
15
'''
16
-
+def camel2snake(word:str):
17
+ result=''
18
+ for char in word:
19
+ if char.isupper():
20
+ result += "_"+char.lower()
21
+ else:
22
+ result +=char
23
+ return result
24
25
26
Now make one that does the opposite: snake2camel()
27
28
+def snake2camel(word:str):
29
+ lst=word.split('_')
30
+ result=lst[0]
31
+ for i in range(1,len(lst)):
32
+ result+=lst[i].capitalize()
33
34
35
def foo():
36
pass
0 commit comments