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
Post a Comment