#### Category : list-comprehension

I am writing a program that defines two functions called Funct() and Funct1(). Both receive following a given list: Name = [‘Sai’, ‘Rusheel’,’Vinay’] Enroll_no. = [80,90,85] Subject = [‘Maths’, ‘Computer’, ‘Science’] Both functions should form a sentence by picking elements from these lists and return them. I use for loops in dosp_1() and list comprehension ..

I have 4 lists and i want to have a final list with the maximum of each index of all lists and also to which list it belongs If it is from first list i mark ‘a’ ,and so on… But i have a problem with list comprehension.There is a syntax which i cannot find: ..

I have a problem for checking the interweaving strings. So, I have 3 strings and I need to check whether the third string can be formed by interweaving the first two strings. To simplify, interweaving strings means to merge them by alternating their letters without any specific pattern. For example: "abc" and "123" are two ..

I have a long list of values and want a list comprehension to evaluate to True (and print "True" only once if any value in the list is the integer 1). I can print "True" for each instance a 1 is found but cannot see how to just have it return a single True. Code ..

i’m a new learner of python. tring to write below code using for loop lst = [ x**2 for x in [x**2 for x in range(11)]] I tryed it this way lst = [] for x in lst: lst.append(x) for x in range(0,11): lst.append(x) but couldn’t identify my mistake. please help to solve it. Source: ..

I have the following digits: 4 5 5 5 6 6 4 1 4 4 3 6 6 3 6 1 4 5 5 5 I want to create a list comprehension that will match me all the same values in a 2d array of lists like: [[1, 1], [3, 3], [4, 4, 4, 4, ..

”’ entry = [["D 300"],["D 300"],["W 200"],["D 100"]] def bankbalance(entry): deposits = [float(entry[ent][0][2:]) for ent in entry if ("D" in entry[ent][0])] withdrawals = [float(entry[ent][0][2:]) for ent in entry if ("W" in entry[ent][0])] global balance balance = sum(deposits) – sum(withdrawals) bankbalance(entry) Print(f’Current balance is {balance}’) ”’ TypeError Traceback (most recent call last) in 9 balance = ..