+ 5
[Solved] So I was doing the camel case to snake case thing...
https://sololearn.com/compiler-playground/c5R52aNOb9fB/?ref=app 4 test cases passed, but one failed. And the testcases are shown as hidden (in new here so is there a way to unhide them?), so I don't know what is wrong
12 Answers
+ 6
Tejas Shyam
Read Lothar and Mohammed shoaib's answer carefully.
Your code fails when the first letter is capitalized.
ThisIsCamelCase
becomes:
_this_is_camel_case.
This is wrong.
It should be:
this_is_camel_case.
+ 9
Tejas Shyam ,
this is what the task description says:
...
Every capital letter is replaced with its lowercase prefixed by an underscore _, except for the *first letter*, which is lowercased without the underscore, so that SomeName becomes some_name.
...
>>> check what has to be done with the *first letter*.
+ 6
They were intentionally locked 🔒 to prevent users from using workarounds ... Everything you needed to know to pass are within the previous pieces of the lesson leading up to the project.
+ 5
I fixed the code, now it works!
I added an if statement to check whether i = 0. Thanks to all of you for the help!
+ 4
ThisIsCamelCase.
You're super close!!! PleaseTryALittleMoreeee
Try to test it yourself
+ 4
Tejas Shyam ,
Cool. What people sometimes do is add [Solved] to the title so people who help know they don't need to open it, and people with the same problem know they can find the solution inside.
+ 4
Rain oh sorry. Im quite new here. Lemme add that [Solved]
+ 3
Just an aside to clear up some confusion about which case is which:
Though I did find one site that seemed to imply that the capitalization of the first word is optional in camel case, the rest said that the first word is not capitalized in camel case.
And they all said that the first word is capitalized in pascal case.
In other words, going with the majority view,
ThisIsNotCamelCase
thisIsCamelCase (not used in Python)
ThisIsPascalCase (classes and exceptions in Python)
and while we're at it,
this_is_snake_case (variables, functions, and methods in Python)
THIS_IS_SCREAMING_SNAKE_CASE (global constants and class constants in Python, even though they're technically not constant, since Python doesn't prevent them being accidentally reassigned or overwritten)
For the purpose of the exercise, I would say the code should be able to accept input in either camel case or pascal case and output snake case.
+ 3
Then there is the lowerCamelCase, which starts with lower case, and the UpperCamelCase that starts with a capital letter and can be considered to be the equivalent of PascalCase and is in my opinion, invented just to add to the confusion and avoid admitting you messed up the definitions ...😅
maybe a cHAoS case, where you randomly mix upper and lower case?
+ 3
Bob_Li ,
True. With the extra adjectives, lower camel case and upper camel case become non-confusable though verbose.
I thought of one to invent, though I'm probably not the first.
thisIsDromedarycase (missing the back hump)
This nice table of Python conventions avoids the confusion with CapWords.
https://namingconvention.org/python/
+ 2
ادم محمد الصالح
Hey Saleh!
Try interacting with the community, I think talking to others, answering their questions and socializing are great ways to bring traffic to your profile!
Btw why tf are people farming follows on sololearn???
0
Since 4 test cases passed, it mean it is one specific scenario that causes an error. And this makes it much more harder to find the problem because I don't know the scenario