camelCase to snake_case

Lab Python Intermediate 20 points

Read an identifier in camelCase and print it in snake_case.

Input

One identifier, e.g. userFirstName.

Output

e.g. user_first_name

Example

Input

userFirstName

Output

user_first_name
Sample input available Sample output available
Editor
Python

Hints

Each uppercase letter becomes an underscore plus the lowercase letter.

Solution explanation

Building a new string character by character is fine for short strings; for long ones, collect pieces in a list and join them.

Show solution
name = input()
result = ""
for ch in name:
    if ch.isupper():
        result += "_" + ch.lower()
    else:
        result += ch
print(result)
Output
Answer
HOME LEARN COMMUNITY DASHBOARD