22222
ABC 394Problem 22 of 50
EasyWhat to do
Given a string of digits, remove every character that is not '2' and return the remaining string. For example, '20250222' → '22222'.
Key Concepts
string manipulation
loops
conditional statements
Examples
Input:
s = '20250222'
Output:
22222
Input:
s = '2'
Output:
2
Tips for Beginners
- Focus on understanding the logic, not memorizing syntax
- Use print statements to debug your code
- Don't worry about input parsing - the function handles that for you
- If stuck, try writing out your solution on paper first
Python Editor
Loading Python...