Logic Building
# Take string input
s = input("Enter a string: ")
# Remove last character
if len(s) > 0:
result = s[:-1]
print(f"After removal: {result}")
else:
print("String is empty")Output
Enter a string: Hello After removal: Hell
Use slicing to skip last character.
Key Concepts:
- s[:-1] excludes last character
- Returns substring
- Check if string not empty