14 May Aurora Wednesday Saturday Python Homework 20.05.13.
Question:
Create a Word class from a string.
- You need one argument (which is the original string) to create the object.
- def __init__(self, original):
- You need one method to reverse the string
- def reverse(self):
- You can print the object with the following expected output if the sample String is ‘1234abcd’
-
'1234abcd' => 'dcba4321'
-
Hint:
You should consider to use attributes to save the original string and reversed string.
You can write the main program like following:
myString = input('Please enter a string: ') wr = Word(myString) wr.reverse() print(wr)
Sorry, the comment form is closed at this time.