Skip to content
Advertisement

Tag: list

What do ellipsis […] mean in a list?

I was playing around in python. I used the following code in IDLE: The output was: What is this […]? Interestingly I could now use this as a list of list of list up to infinity i.e. I could write the above as long as I wanted and it would still work. EDIT: How is it represented in memory? What’s

Python assigning multiple variables to same value? list behavior

I tried to use multiple assignment as show below to initialize variables, but I got confused by the behavior, I expect to reassign the values list separately, I mean b[0] and c[0] equal 0 as before. Result is: [1, 3, 5] [1, 3, 5] [1, 3, 5] Is that correct? what should I use for multiple assignment? what is different

Possible to append multiple lists at once? (Python)

I have a bunch of lists I want to append to a single list that is sort of the “main” list in a program I’m trying to write. Is there a way to do this in one line of code rather than like 10? I’m a beginner so I have no idea… For a better picture of my question, what

Add SUM of values of two LISTS into new LIST

I have the following two lists: Now I want to add the items from both of these lists into a new list. output should be Answer The zip function is useful here, used with a list comprehension. If you have a list of lists (instead of just two lists):

Advertisement