Lets say I have a simple console program where user can input some text. And suppose I have class as follows:
class A:
def __init__(self, some_string):
self.lens=len(some_string)
def PrintLen(self):
print(self.lens)
Suppose that user input some text consisting of only one word (lets say - 'word'
).
My question is how can I make 'word'
to become instance of class A
that I can use word.PrintLen()
without any errors? I guess I should implement some function that converts string object to my class object but I don't know how to realize that.