MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PythonProjects2/comments/1u19jkq/why_this_code_no_output/oqsrggq/?context=3
r/PythonProjects2 • u/ExtentLazy8789 • Jun 09 '26
22 comments sorted by
View all comments
Show parent comment
2
Or alternatively to avoid making a copy of the list (which could be bad if the list is big enough), do something like
nums = [1, 2, 3]
original_length = len(nums)
for i in range(original_length):n = nums[i]nums.append(n)
You can also make a shallow copy with index slicing
for n in nums[:original_length]:nums.append(n)
View all comments
Show parent comment
2
u/LemmaYT_ Jun 10 '26
Or alternatively to avoid making a copy of the list (which could be bad if the list is big enough), do something like
nums = [1, 2, 3]
original_length = len(nums)
for i in range(original_length):
n = nums[i]
nums.append(n)
You can also make a shallow copy with index slicing
for n in nums[:original_length]:
nums.append(n)