Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
output values change
#1
hi
int the below code:
def something(num,my_list):
    num=3
    my_list[0]=3

a=2
b=[2]
something(a,b)
print(a)
# 2 is printed
print(b)
#[3] is printed
the value of a in the final is the same as before, but the b value has changed. Why?
I read somewhere something before it, but i can not understand it. can you explain it?
thanks
Reply


Messages In This Thread
output values change - by akbarza - Oct-17-2023, 10:14 AM
RE: output values change - by deanhystad - Oct-17-2023, 11:09 AM
RE: output values change - by akbarza - Oct-18-2023, 07:58 AM
RE: output values change - by deanhystad - Oct-18-2023, 12:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find a specific keyword after another keyword and change the output sgtmcc 5 886 Oct-05-2023, 07:41 PM
Last Post: deanhystad
  Rain sensor output only on change Pete6 3 2,076 May-11-2022, 10:36 PM
Last Post: Pete6
  change numerical values to categorical names JoeOpdenaker 3 2,982 Nov-02-2020, 01:32 PM
Last Post: DeaD_EyE
  change array column values without loop khalidreemy 2 3,856 May-05-2019, 09:05 AM
Last Post: DeaD_EyE
  Change Text Color Output in Python bluethundr 2 8,776 Mar-06-2019, 10:23 PM
Last Post: bluethundr
  Confusing output from 2to3 about what files need change Moonwatcher 1 4,858 Dec-30-2018, 04:07 PM
Last Post: Gribouillis
  Change output of cells. Hoogoo 2 2,648 Nov-19-2018, 12:47 AM
Last Post: Larz60+
  Change values in string multiline DavidFernandez 4 3,150 Aug-26-2018, 08:09 PM
Last Post: buran
  Change the output window size and display area issac_n 0 2,286 Apr-13-2018, 04:41 AM
Last Post: issac_n
  Change Windows Sound Output Device with Python delfar 1 10,373 Sep-15-2017, 12:11 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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