+ 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

14th Dec 2023, 6:13 PM
Tejas Shyam
Tejas Shyam - avatar
12 Antworten
+ 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.
14th Dec 2023, 9:30 PM
Bob_Li
Bob_Li - avatar
+ 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*.
14th Dec 2023, 6:57 PM
Lothar
Lothar - avatar
+ 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.
14th Dec 2023, 6:31 PM
BroFar
BroFar - avatar
+ 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!
15th Dec 2023, 5:42 AM
Tejas Shyam
Tejas Shyam - avatar
+ 4
ThisIsCamelCase. You're super close!!! PleaseTryALittleMoreeee Try to test it yourself
14th Dec 2023, 6:48 PM
Mohammed shoaib
+ 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.
15th Dec 2023, 5:46 AM
Rain
Rain - avatar
+ 4
Rain oh sorry. Im quite new here. Lemme add that [Solved]
15th Dec 2023, 5:53 AM
Tejas Shyam
Tejas Shyam - avatar
+ 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.
15th Dec 2023, 4:57 AM
Rain
Rain - avatar
+ 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?
15th Dec 2023, 5:28 AM
Bob_Li
Bob_Li - avatar
+ 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/
15th Dec 2023, 5:40 AM
Rain
Rain - avatar
+ 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???
15th Dec 2023, 2:33 PM
Mohammed shoaib
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
14th Dec 2023, 6:52 PM
Tejas Shyam
Tejas Shyam - avatar