Python Forum
Keeping a value the same despite changing the variable it was equated to
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keeping a value the same despite changing the variable it was equated to
#2
Might can do something like this

currentPath = ["EWR", "JFK", "SFO"]
completedPaths = []

# completedPaths.append(currentPath.copy())
# or maybe
completedPaths = completedPaths + currentPath
print(completedPaths)

currentPath.clear()
print(currentPath)
print(completedPaths)
Output:
[['EWR', 'JFK', 'SFO']] [] [['EWR', 'JFK', 'SFO']]
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
RE: Keeping a value the same despite changing the variable it was equated to - by menator01 - Mar-13-2022, 10:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Keeping up with IDEs and Virtual Environments... bytecrunch 7 2,688 Sep-05-2022, 08:04 PM
Last Post: snippsat
  Problem keeping the window up benlyboy 11 4,293 Jan-24-2020, 02:12 AM
Last Post: tamilselvisubbiah
  Changing a variable's name on each iteration of a loop rix 6 85,446 Jan-03-2020, 07:06 AM
Last Post: perfringo
  merging lists, dedup and keeping order, in older pythons Skaperen 3 3,229 Oct-19-2018, 01:30 AM
Last Post: ODIS
  Keeping Intersection of an Image Only Anysja 4 3,031 Aug-15-2018, 09:47 PM
Last Post: Anysja
  help with keeping score W3BL3Y 2 6,339 Apr-29-2018, 01:12 PM
Last Post: W3BL3Y
  int(variable) not changing variable to an integer StoopidChicken 2 3,016 Jan-11-2018, 10:30 AM
Last Post: StoopidChicken
  Questions on variable changing between files. Sello 12 7,245 Apr-25-2017, 04:59 AM
Last Post: wavic
  changing variable outside of a function tkj80 8 7,348 Jan-05-2017, 03:52 AM
Last Post: tkj80

Forum Jump:

User Panel Messages

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