list tag

251 questions


1 answers
77 views
0
How do I erase elements while writing std::list?

for (std::list<item*>::iterator i=items.begin();i!=items.end();i++){ bool isActive = (*i)->update(); //if (!isActive) // // items.remove(*i); //else other_code_involving(*i);}items.remove_...

2 years ago

1 answers
174 views
0
To randomly mix elements in a list

I want to mix the list that stores the objects.random.shuffle I don't know why, but None keeps returning, so I can't write it.I think it's because there's an object in the list, not a normal type like...

2 years ago

1 answers
113 views
0
How do I process True only when the object is a list or tuple, and False when the string is false?

If an object is a list/tuple, you want to continue to run the program, and if it is a string, you want to create a script that says assert.assert isinstance(lst, list) or isinstance(lst,tuple)Is there...

2 years ago

1 answers
167 views
0
I'd like to share all the lists

L = [[[1, 2, 3], [4, 5]], 6]If the element in the list is a list like this [1, 2, 3, 4, 5, 6]I'm going to release all the elements of the list together.The way I know it, the list is[[1,2], [3,4], 5] ...


1 answers
183 views
0
What do you compare the contents() method of ArrayList?

ArrayList<Thing> basket = new ArrayList<Thing>(); Thing thing = new Thing(100); basket.add(thing); Thing another = new Thing(100); basket.contains(another); // true or false?class Thing { ...


1 answers
157 views
0
How to erase only the first element in the list

[0, 1, 2, 3, 4] -> [1, 2, 3, 4]I'd like to remove the first element of the list together. Is there a function that does this?As I did, I don't think I need to use the for statement, but I don't kno...

2 years ago

1 answers
154 views
0
I'm going to compare the two lists and get only the elements that don't exist back

I want to compare the two lists and get only the elements that are not in each other returned For example, temp1 = ['One', 'Two', 'Three', 'Four']temp2 = ['One', 'Two']temp3 = [Three, Four]I want to w...

2 years ago

1 answers
90 views
0
How to replace an Integer ArrayList with an int array

To replace the Integer type ArrayList with an int type array List<Integer> x = new ArrayList<Integer>();int[] n = (int[])x.toArray(int[x.size()]);I did this, but there is a compilation err...


1 answers
147 views
0
I want to know a better way to throw away all the elements on the list.

mylist1 = [1,2,3]mylist2 = mylist1mylist2 = []This clears the existing reference. What I want is that if you change mylist2, mylist1 will also be emptied, so I can't use that code.I'm writing it like ...

2 years ago

1 answers
89 views
0
Question! I'm going to write a list element in the file

You are about to write a list element to a file. For example, #PythonFilemylist = [hello, 3]file = open(myfile.txt, w)file.writelines([%s\n % item for item in mylist])When you run myfile.txthello3Let'...

« - 2 - »

© 2024 OneMinuteCode. All rights reserved.