Making a case converter, while learning python list comprehension, in 'Scientific Computing with Python'

How do i prepend the char in the for loop and make a lowercase character when the letter is uppercase?

def convert_to_snake_case(pascal_or_camel_cased_string):
    snake_cased_char_list = []
    for char in pascal_or_camel_cased_string:
        if char.isupper():    
        converted_character = char.lower().insert(char,'_')  

<— Here i tried to make it
lowercase, and then prepend

He. Welcome to the community. Please can you link to the url of the step you are stuck on.

1 Like

str object do not have an insert function. try this intead:
[solution removed by moderator]

1 Like

Hi. I have removed the solution from your post. We guide users to work out the solution for themselves on the forum.

1 Like

Very sorry for that, did not know about this. Thank you for informing me about this :slight_smile:

1 Like

prepend means “add before”, you do not need any method or function for this

Thank you, i done it. Thanks that really helped. Thanks, appreciate the help