TORONTO KIDS COMPUTER CLUB | Aurora Wednesday Saturday Python Homework 20.05.13.
17498
post-template-default,single,single-post,postid-17498,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Aurora Wednesday Saturday Python Homework 20.05.13.

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)
No Comments

Sorry, the comment form is closed at this time.