```{.python}from random import randint
'''generating password'''
def generate_password():
password = []
print('YOUR PASSWORD IS 3-DIGITS NUMBER(there\'s no repetition)\n')
while len(password) < 3:
num = randint(0, 9)
if num not in password:
password.append(num)
return password
'''input password'''
def user_input():
guess = []
print('ENTER PASSWORD')
while len(guess) < 3:
num = int(input('digit: '))
guess.append(num)
return guess
'''check'''
def check(answer, user):
right = 0
for i in range(0, 3):
if user[i] in answer:
right += 1
print('{} of them is/are right\n'.format(right))
'''start'''
ANSWER = generate_password()
while True:
user_guess = user_input()
check(user_guess, ANSWER)
if user_guess == ANSWER:
break
print('UNLOCKED!')
```
온라인 강의에서 배운 코드를 변형해서 사용해봤습니다!
```{.python}from random import randint
'''generating password'''
def generate_password():
password = []
print('YOUR PASSWORD IS 3-DIGITS NUMBER(there\'s no repetition)\n')
while len(password) < 3:
num = randint(0, 9)
if num not in password:
password.append(num)
return password
'''input password'''
def user_input():
guess = []
print('ENTER PASSWORD')
while len(guess) < 3:
num = int(input('digit: '))
guess.append(num)
return guess
'''check'''
def check(answer, user):
right = 0
for i in range(0, 3):
if user[i] in answer:
right += 1
print('{} of them is/are right\n'.format(right))
'''start'''
ANSWER = generate_password()
while True:
user_guess = user_input()
check(user_guess, ANSWER)
if user_guess == ANSWER:
break
print('UNLOCKED!')
```
온라인 강의에서 배운 코드를 변형해서 사용해봤습니다!