Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
while loops
#6
Indeed, the instructions suggest one loop with exclusion of the bad names as soon as they are entered. But, your example desired output suggests that all names are added and then a second loop goes through that list and does the exclusions.

So which is it?

If the latter, I would build a second list of names from the first, adding a name only if it is not in the bad name list.
good_list = []
for name in users:
    if name not in banned_users:
        good_list.append(name)
Paulman likes this post
Reply


Messages In This Thread
while loops - by Paulman - Oct-18-2021, 04:13 PM
RE: while loops - by Yoriz - Oct-18-2021, 04:35 PM
RE: while loops - by deanhystad - Oct-18-2021, 05:25 PM
RE: while loops - by Yoriz - Oct-18-2021, 05:32 PM
RE: while loops - by deanhystad - Oct-18-2021, 05:55 PM
RE: while loops - by jefsummers - Oct-18-2021, 08:08 PM
RE: while loops - by Paulman - Oct-18-2021, 08:48 PM
RE: while loops - by ibreeden - Oct-19-2021, 01:36 PM
RE: while loops - by Ghazi - Oct-20-2021, 09:16 AM
RE: while loops - by Paulman - Oct-20-2021, 02:14 PM
RE: while loops - by Paulman - Oct-20-2021, 02:44 PM
RE: while loops - by deanhystad - Oct-20-2021, 02:54 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020