Remove Last Character
Remove last character from string.
BeginnerPhase 5 - Category 4: String TransformationExample 5 of 10
remove-last-character.py
1# Take string input2s = input("Enter a string: ")34# Remove last character5if len(s) > 0:6 result = s[:-1]7 print(f"After removal: {result}")8else:9 print("String is empty")
Output
Enter a string: Hello After removal: Hell
What's going on
Use slicing to skip last character.
Key Concepts:
s[:-1] excludes last character
Returns substring
Check if string not empty
🔗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