Tell us what’s happening:
Can someone help me in this step i am not sure what to do here
Your code so far
def convert_to_snake_case(pascal_or_camel_cased_string):
snake_cased_char_list = []
for char in pascal_or_camel_cased_string:
# User Editable Region
if char.isupper():
converted_character
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Learn Python List Comprehension by Building a Case Converter Program - Step 5
Hi. You need to assign a value to the variable named converted_character. You haven’t done this. The value to be assigned is stated in the instructions:
Use the .lower() string method to convert uppercase characters to lowercase characters. Then, prepend an underscore to the character.
Post your updated code if you are still having problems.
i am unable to understand what is the step you want me to do i can create a variable name converted_character by what to assign to it i am not sure can you please help me?
OK let’s break it down. The condition of your if statement is to ask whether the character is in upper case. If it is then the code to be executed inside the if statement is to firstly convert the characters to lower case. That is the first value to assign to your variable. How will you write that to start off?
Post your code with that value assigned and then we can move on to the next part.
can you explain it in step by step please
OK. Can you see what character you need to convert? The condition to the if statement gives a hint.
How do you convert a string or a character variable to lowercase?
by applying lower or islower at the end of statement but where to put this in the code?
Yes, using the correct syntax. The instructions give the method:
.lower()
You need to apply the method to something - what are you applying the lowercase method to? You need to attach it to something.
Once you have worked this out, this is one of the values that you assign to your converted_character variable. You said you know how to create a variable..
sorry still the same issue
OK I thought you understood how to do lowercase. If you created this variable, how would you convert it to lowercase?
x = "JOHN";
tried this but still its not taking my inputs
OK can you post your updated code so we can see what you have tried?
sure i will share in sometime
this is what i have given input please let me know what is the right way to do it
Yes that’s how to use lower and an example of assigning a value to your variable called converted_character. Now what are to asked to put to lower case in the instructions? Which variable?
Please don’t post pictures of your code.
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
i am not sure where else to put the lowecase character
You are putting it in the right place but you have not attached it to the right variable, obviously your name is an example.
What is the condition in the if statement saying?
if char.isupper():
``
the character isupper so you want me to replace isupper with islower?
That should give you a hint as to what variable you are attaching lower to. The condition is saying if the char variable is in uppercase execute the code in the execution statement. The code to be executed is to convert any upper case characters to lowercase.
No don’t change the condition, you are just working on the converted_character variable at present.
You need to change “PUNIT” in your code above, to the correct variable to attach to lower().