Используйте метод ниже:
def find_sub_list(sl,l):
sll=len(sl)
for ind in (i for i,e in enumerate(l) if e==sl[0]):
if l[ind:ind+sll]==sl:
return ind,ind+sll-1
find_sub_list([1,2,3], data)
>>>(2, 4)
find_sub_list([4,5,6], data)
>>>(8, 10)
data[2:10+1]
>>>[1, 2, 3, 99, 99, 99, 4, 5, 6]
Вы можете использовать аналогичный подход для sublists[1]
Предоставлено: find-start-and-end-index-of- подсписок-в-списке
Вот решение проблемы, которую я уже понял.
Линия if typed_password == "12345":
не будет работать, пока пользователь не введет правильный пароль
Исправить: добавить его в [ 117] elif оператор
Если result
должен показать желаемое сообщение, например Access Granted
или Access Denied!!
или That password is one that an idiot puts on their luggage!!!
Исправить: Использовать [ 116] функция
password_file = open('SecretPasswordFile.txt')
secret_password = password_file.read().rstrip() # fix : added rstrip() to trim whitespaces from the right side
typed_password = input("Enter your Password!: ")
if typed_password == secret_password:
print ("Access granted!")
elif typed_password == "12345":
print("That password is one that an idiot puts on their luggage!!!")
else:
print('Access Denied!!')