Alex Rivera | Logout

How to replace uppercase with underscore?

Asked 2011-09-06T15:03:48.397
16

I'm new to Python and I am trying to replace all uppercase-letters within a word to underscores, for example:

ThisIsAGoodExample

should become

this_is_a_good_example

Any ideas/tips/links/tutorials on how to achieve this?

Edit
Report

1 Answer

0

Parse your string, each time you encounter an upper case letter, insert an _ before it and then switch the found character to lower case

answered 2011-09-06T15:12:08.853

Your Answer