The composition from 93 For python pleaseSolutionclass Lock

The composition from 9-3

For python please.

Solution

class Lock:
    code = \"\"
    def __init__(self, code):
        if len(code)==3:
            self.code = code
        else:
            print \"Please enter a 3 digit code\"

    def change_code(self, code):
        if len(code)==3:
            self.code = code
        else:
            print \"Please enter a 3 digit code\"

    def open_lock(self, code):
        if code == self.code:
            print \"Correct Code. Lock opened\"
        else:
            print \"Incorrect code. Lock not opened\"

code = raw_input(\"Input the lock for new code: \")
lock = Lock(code)

code_change = raw_input(\"Change a new code if you wish to change the current code: \")
lock.change_code(code_change)

code_open = raw_input(\"Enter the code to open the lock: \")
lock.open_lock(code_open)

The composition from 9-3 For python please.Solutionclass Lock: code = \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site