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 ..

Read more

”’ 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 = ..

Read more