Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list not working
#1
    from __future__ import division
    import time, math

    List = [3,4,6]

    MADlist = List
    for i in range(len(MADlist)):
      MADlist[i] -= mean
      MADlist[i] = math.fabs(MADlist[i])
    MADsum = float(sum(MADlist))
    MAD = MADsum/(len(MADlist))
Here's my code.

I have a list called List. I want to make some changes without actually changing List, so I create another list, MADlist, to make changes to while keeping the original list the same. For whatever reason, it makes the same changes to the original list too! Why?
Reply


Messages In This Thread
list not working - by Zman350x - Mar-10-2018, 12:06 AM
RE: list not working - by Larz60+ - Mar-10-2018, 12:14 AM
RE: list not working - by Zman350x - Mar-10-2018, 12:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  os.list dir not working Kristenl2784 8 10,119 Jul-29-2020, 04:22 PM
Last Post: deanhystad
  python3: iterating through list not working wardancer84 3 2,376 Jul-08-2020, 04:30 PM
Last Post: DPaul
  Finding MINIMUM number in a random list is not working Mona 5 3,090 Nov-18-2019, 07:27 PM
Last Post: ThomasL
  Appending to list not working and causing a infinite loop eiger23 8 4,022 Oct-10-2019, 03:41 PM
Last Post: eiger23

Forum Jump:

User Panel Messages

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