#227 · Strings · Beginner · 30 XP · about 5 min
Python names are usually written in snake case (user_first_name), while JavaScript prefers camel case (userFirstName). Write snake_to_camel(name) that converts a snake case name to camel case.
The underscores split the name into pieces. The first piece stays as it is, every later piece gets a capital first letter, and the pieces are joined with no underscores. A piece that starts with a digit stays as it is.
Empty pieces, which come from underscores at the start or the end or from two underscores in a row, are skipped. A name with no pieces at all gives an empty string.
snake_to_camel("user_first_name") # returns 'userFirstName' snake_to_camel("total") # returns 'total' snake_to_camel("max_retry_count_3") # returns 'maxRetryCount3' snake_to_camel("_private_value") # returns 'privateValue'
name contains only lowercase letters, digits and underscores.
First solves only, ranked by stars and then time.