class - Beginner Python Classes - changing the attribute value with user input -


i learning classes in python , past day stuck below.

i trying use user input (from main() function) change value of attribute in class.

i have been throught @property , @name.setter methods allow change value of private attribute.

however trying find out how can use user input change value of attribute not private.

i came below not seem work. value of attribute remains same after run program. have ideas why?

    class person(object):      def __init__(self, loud, choice = ""):         self.loud = loud         self.choice = choice      def userinput(self):         self.choice = input("choose want: ")         return self.choice      def choiceimpl(self):         self.loud == self.choice      def main():          john = person(loud = 100)          while true:              john.userinput()              john.choiceimpl()              print(john.choice)             print(john.loud)      main() 

in choiceimpl using == should use =.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -