Я пытаюсь заменить элемент в списке не обязательно в конце, просто позицию исходного элемента, а затем потребовать новый элемент, когда он просит вас для вашего пароля. Я новичок в Python.Пытаться заменить элемент в списке другим товаром
passwords = ['mrjoebblock' , 'mrjoefblock' , 'mrjoegblock', 'mrjoeadmin' ]
if choice == '3':
password = raw_input('Welcome admin! I\'m going to need your password ')
if password == 'mrjoeadmin':
print('Welcome Mr. Joe!')
Choice11 = raw_input('What would you like to do? Press 1 for changing your admin password, 2 for viewing a class\'s comments, or 3 for changing a class\'s password')
if Choice11 == '1':
print('You have chosen to change your password! ')
Choice12 = raw_input('You will need to put in your current password to access this feature ')
if Choice12 == 'mrjoeadmin':
Choice13 = raw_input('What would you like to change your password to? ')
passwords.remove('mrjoeadmin')
passwords.append(Choice13)
print('Thank you! Password has been changed. Log in with new password next time')
break
if Choice11 == '2':
print('you have chosen to view a class\'s comments!')
Choice14 = raw_input('Which block would you like to view?')
if Choice14 == 'F block':
print('To view F block\'s comments, go to where you search for things in your computer, and search CommentsFblock.txt. Open it')
time.sleep(10)
break
if Choice14 == 'G block':
print('To view G block\'s comments, go to where you search for things in your computer, and search CommentsGblock.txt. Open it')
time.sleep(10)
break
if Choice14 == 'B block':
print('To view B block\'s comments, go to where you search for things in your computer, and search CommentsBblock.txt. Open it')
time.sleep(10)
break
else:
print('I\'m sorry, that\'s not a valid block name.')
time.sleep(2)
break
if Choice11 == '3':
print('you have chosen to change a block\'s password.')
Choice15 = raw_input('Which block\'s password would you like to change?')
if Choice15 == 'F block':
Choice16 = raw_input('You will need to put in your current password to change F block\'s password ')
if Choice16 == 'mrjoeadmin':
Choice17 = raw_input('What would you like to change F block\'s password to? ')
passwords.remove('mrjoefblock')
passwords.append(Choice17)
print('Thank you! Password has been changed. Remember to tell students the password has been changed')
time.sleep(3)
break
if Choice15 == 'G block':
Choice18 = raw_input('You will need to put in your current password to change G block\'s password ')
if Choice18 == 'mrjoeadmin':
Choice19 = raw_input('What would you like to change G block\'s password to? ')
passwords.remove('mrjoegblock')
passwords.append(Choice19)
print('Thank you! Password has been changed. Remember to tell students the password has been changed')
time.sleep(3)
break
if Choice15 == 'B block':
Choice20 = raw_input('You will need to put in your current password to change B block\'s password ')
if Choice20 == 'mrjoeadmin':
Choice21 = raw_input('What would you like to change B block\'s password to? ')
passwords.remove('mrjoebblock')
passwords.append(Choice21)
print('Thank you! Password has been changed. Remember to tell students the password has been changed')
time.sleep(3)
break
Тогда, в чем проблема? – stanleyli
Я пытаюсь заставить его потребовать новый пароль после его изменения –
@KraeganEpsilon Gotcha. Я обновил свой ответ. –