Hey Python enthusiasts!
I'm currently diving into a Python project that involves string manipulation, and I've hit a bit of a roadblock. I've experimented with a few approaches, but none seem to be yielding the desired outcome. Below is a simplified version of my code snippet, along with the specific issue:
class StringManipulator:
def concatenate_strings(self, str1, str2):
# Concatenate str1 and str2
return str1 + str2
def reverse_string(self, input_str):
# Reverse the characters in the input string
# e.g., "hello" should become "olleh"
return input_str[::-1]
def capitalize_string(self, input_str):
# Capitalize the first letter of the input string
# e.g., "python" should become "Python"
return input_str.capitalize()
Issue:
While the concatenate_strings method seems to be working fine, I'm encountering problems with the reverse_string and capitalize_string methods. The reversed string and capitalized string aren't turning out as expected.
I'd really appreciate any suggestions or corrections to my code. Thanks a ton!