Remove Character
Remove all occurrences of a character.
IntermediatePhase 5 - Category 4: String TransformationExample 2 of 10
remove-character.py
1# Take string input2s = input("Enter a string: ")3char_to_remove = input("Enter character to remove: ")45# Remove6result = s.replace(char_to_remove, "")7print(f"After removal: {result}")
Output
Enter a string: Hello Enter character to remove: l After removal: Heo
What's going on
Replace character with empty string.
Key Concepts:
Replace with "" to remove
All occurrences removed
Returns new string
🔗Related Content
- 📖
Phase 5 - Learn Concepts
Review Phase 5 concepts and explanations
- 📝
Phase 5 - Quiz
Test your Phase 5 understanding with quiz questions
- 💻
Phase 5 - All Practice Problems
Explore all practice problems for Phase 5
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum