![]() |
Loop inside loop inside loop - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Loop inside loop inside loop (/thread-25027.html) |
Loop inside loop inside loop - L0RTK1PAN1DZ3 - Mar-16-2020 Hey guys How to break nested loop? RE: Loop inside loop inside loop - buran - Mar-16-2020 can you show sample code and explain better what you want (e.g. break out of the inner most loop into upper level, or break out of all netsed loops, etc.), because your setup is not very clear. Otherwise the answer is to use break .
RE: Loop inside loop inside loop - perfringo - Mar-16-2020 Maybe one of my earlier answers to similar question helps. RE: Loop inside loop inside loop - L0RTK1PAN1DZ3 - Mar-16-2020 (Mar-16-2020, 09:52 AM)buran Wrote: can you show sample code and explain better what you want (e.g. break out of the inner most loop into upper level, or break out of all netsed loops, etc.), because your setup is not very clear. Otherwise the answer is to use elements = "qwertyuiop" elements_list = list(elements) password = input("enter: ") for a in elements_list: ////for b in elements_list: ////////for c in elements_list: ////////////print(a+b+c) ////////////if a+b+c == password: ////////////////break RE: Loop inside loop inside loop - buran - Mar-16-2020 Please, use proper tags when post code, traceback, output, etc. See BBcode help for more info. what do you want to achieve? Why do you do all these weird things? If you want to check string is present in list of strings: passwords = ['week_pass', 'fEaPzy0M8#2`pHNS'] password = input('Enter password:') if password in passwords: print('Correct password') |