Python Forum
list is printing incorrectly..
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list is printing incorrectly..
#2
You are appending the same dictionary every time. Unless you do an explicit copy of a dictionary, whenever you modify the dictionary, you modify every other instance of the dictionary you left laying about. That's because the variables are just pointing to the (same) dictionary, not hosting independent versions of it.

I would just condense lines 34-36 into one line: interface_list.append({'switch_ip': reachable_sw, 'port': interface}).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
list is printing incorrectly.. - by anna - May-18-2019, 10:37 AM
RE: list is printing incorrectly.. - by ichabod801 - May-18-2019, 12:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Printing through list.. again jesse68 2 1,160 Apr-16-2022, 03:24 PM
Last Post: jesse68
  help for list printing jip31 8 3,687 May-01-2021, 03:52 AM
Last Post: Pedroski55
  Writing to file ends incorrectly project_science 4 2,711 Jan-06-2021, 06:39 PM
Last Post: bowlofred
  Problem printing last element from a list tester_V 3 2,423 Oct-30-2020, 04:54 AM
Last Post: tester_V
  Printing empty list? hhydration 2 2,142 Oct-28-2020, 11:34 AM
Last Post: Atekka
  Printing images from a list Heyjoe 4 2,840 Jun-22-2020, 02:28 AM
Last Post: Heyjoe
  New to the language. What am I doing incorrectly here? christopher3786 3 2,289 Jun-20-2020, 10:18 AM
Last Post: pyzyx3qwerty
  my openpyxl use is too slow, am I reading rows incorrectly? Clunk_Head 2 8,357 Apr-30-2020, 10:29 PM
Last Post: deac33
  printing a list contents without brackets in a print statement paracelx 1 2,154 Feb-15-2020, 02:15 AM
Last Post: Larz60+
  Printing List in one line bharat_s579 6 4,163 May-26-2019, 08:30 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

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