Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

In python what is the difference between these two? sequence = range(10) buffer = sequence and sequence = range(10) buffer = [item for item in sequence]

OpenStudy (asnaseer):

in the first one, you are creating an alias called 'b' to 's' and therefore any changes to make to 'b' will also change the contents of 's' in the second one, you are using list comprehensions to create a separate copy of 's' in 'b'. so any changes in 'b' now will NOT be reflected in 's'.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!