-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamel_Case.py
More file actions
36 lines (25 loc) · 869 Bytes
/
camel_Case.py
File metadata and controls
36 lines (25 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
''' Write a function to convert a given string to camelCase .
- To obtain a string in camel case, we capitalize the first letter of each word
except the first one.
- Then Join all words without spaces to form the camelCase string.
Input : 'hello world'
Output : 'helloWorld'
Reason: The input string is split into two words: 'hello' and 'world'. In the resulting camelCase string,
only the first letter of the second word is capitalized.
Input : 'this is a test'
Output : thisIsATest
Input : 'convert this to camel case'
Output : convertThisToCamelCase
Input : 'another example here'
Output: anotherExampleHere
'''
def to_camel_case(s):
l = s.split(' ')
print(l)
new = []
new.append(l[0])
print(new)
for i in range(1, len(l)):
new.append(l[i].capitalize())
return ''.join(new)
print(to_camel_case('hello world user'))