[Solved] Iterate over list

You need to break up the rows and convert each value to an integer. At the moment you are looking for the presence of the string “3” which is why strings like “2;13” pass the test. Try something like this: list_6 = [“4;99”, “3;4;8;9;14;18”, “2;3;8;12;18”, “2;3;11;18”, “2;3;8;18”, “2;3;4;5;6;7;8;9;11;12;15;16;17;18”, “2;3;4;8;9;10;11;13;18”, “1;3;4;5;6;7;13;16;17”, “2;3;4;5;6;7;8;9;11;12;14;15;18”, “3;11;18”, “2;3;5;8;9;11;12;13;15;16;17;18”, “2;5;11;18”, “1;2;3;4;5;8;9;11;17;18”, … Read more

[Solved] Create list from user input and modify some elements

If you dont want to use list comprehension: my_list=[] for i in range(5): n=int(input(“Enter and integer number:”)) my_list.append(n) print(my_list) for index, i in enumerate(my_list): if i%5==0: my_list[index] = i + 5 print (my_list) 1 solved Create list from user input and modify some elements

[Solved] Remove quotes from list items without making it a string

You may use below list comprehension using map with eval(…) as: import ast Users = [‘Protein(“SAHDSJDSFJH”), {“id”: “s1”}’, ‘Protein(“ACGTWZJSFNM”), {“id”: “s2”}’, ‘Protein(“ABHZZEQTAAB”), {“id”: “s3”}’] new_list = [y for x in map(eval, Users) for y in x] where new_list will hold the value: [Protein(“SAHDSJDSFJH”), {‘id’: ‘s1’}, Protein(“ACGTWZJSFNM”), {‘id’: ‘s2’}, Protein(“ABHZZEQTAAB”), {‘id’: ‘s3’}] PS: Note that there … Read more

[Solved] Syntax error on token “.”, @ expected after this token [duplicate]

When you do Type[] arr = { …, … }; that’s an array initializer. It can only be used in array declarations (or in array creation expressions, i.e. new String[]{“a”, “b”}). Arrays.asList is defined to take varargs arguments (asList(T… a)), so you do not have to wrap your arguments in an array first: Arrays.asList(“text”, “tek1”) … Read more

[Solved] how to modify the output [closed]

While this code is not pretty to do what your’re looking to do you need to change these lines if num>0: l+='”‘+ str(k) + ‘”=’ + str(num)+’ ‘ True if True: lst+=[l] If you change it to something like if num>0: l+='”‘+ str(k) + ‘”=’ + str(num)+’ ‘ flag = True if flag: lst+=[l] and … Read more

[Solved] How to change this list tuple into list only in Python? [closed]

test = [[(u’hello’,), (u’hello’,)], [(u’hello’,)]] for i, part_i in enumerate(test): for j, part_j in enumerate(part_i): test[i][j] = str(part_j[0]) Or, if you prefer the one-line version: test = [[(u’hello’,), (u’hello’,)], [(u’hello’,)]] result = [[str(j[0]) for j in i] for i in test] solved How to change this list tuple into list only in Python? [closed]

[Solved] Why is it giving me the error “method ArrayList.add(String) is not applicable”?

Problem: ArrayList<String> means you want an array-backed list that can hold String objects. This restricts the add method to only accept strings. The mistake you are making is that you are passing other non-String objects into the add method. Bad Answer 1: The easy way out is to change it to ArrayList<Object>, but this defeats … Read more

[Solved] how to remove [ , ] and single quote in class list in python 3 in single line of code? [closed]

Based on your update on what bid_data contains: Do: int(bid_data[6].split(‘:’)[1].strip()) # returns an integer Explanation: The Python string method strip() removes excess whitespace from both ends of a string (without arguments) Original below: Below is based on using the input you gave, [‘Quantity Required’, ‘ 1’], to get the output of 1 If the input … Read more