Python Forum
Help with Logical error processing List of strings
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Logical error processing List of strings
#1
This code is to remove one item from a List of "names" until the List is empty using for loop. The program does not complete the List stopping before the list is empty. See output 5 items on original List. Only 3 items removed
# Simple Test to empty List using loop
List_of_Users = ['josh', 'admin', 'cookie','jerry','jack']   
#
print("Starting List Below:")
print(List_of_Users)
Size_of_List = len(List_of_Users)
print(f"The List contains {Size_of_List} members")
for User in List_of_Users:
    List_of_Users.pop(0)
    print(f"The new List: {List_of_Users} ")
    Size_of_List = len(List_of_Users)
    print(f"The List contains {Size_of_List} members")
    print("")
Output:
Output:
Starting List Below: ['josh', 'admin', 'cookie', 'jerry', 'jack'] The List contains 5 members The new List: ['admin', 'cookie', 'jerry', 'jack'] The List contains 4 members The new List: ['cookie', 'jerry', 'jack'] The List contains 3 members The new List: ['jerry', 'jack'] The List contains 2 members [Finished in 254ms]
Yoriz write Nov-26-2022, 04:27 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Help with Logical error processing List of strings - by dmc8300 - Nov-26-2022, 03:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read module/class from list of strings? popular_dog 1 485 Oct-04-2023, 03:08 PM
Last Post: deanhystad
  Trying to understand strings and lists of strings Konstantin23 2 776 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  problem in using int() with a list of strings akbarza 4 716 Jul-19-2023, 06:46 PM
Last Post: deanhystad
  Delete strings from a list to create a new only number list Dvdscot 8 1,554 May-01-2023, 09:06 PM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,780 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Convert each element of a list to a string for processing tester_V 6 5,361 Jun-16-2021, 02:11 AM
Last Post: tester_V
  Greedy algorithms on logical problems Opensourcehacker 0 1,541 Nov-22-2020, 05:12 PM
Last Post: Opensourcehacker
  Strange syntax error with f-strings Askic 6 4,230 Oct-16-2020, 10:40 AM
Last Post: Askic
  Unable to bit shift and logical OR bytes and ints? MysticLord 7 7,043 Sep-01-2020, 03:31 PM
Last Post: deanhystad
  Basic logical errors cpopescu 3 2,069 Jun-03-2020, 11:30 AM
Last Post: menator01

Forum Jump:

User Panel Messages

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